centos7下使用wget命令安装mysql

Posted zhangjiahao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7下使用wget命令安装mysql相关的知识,希望对你有一定的参考价值。

1.首先安装wget命令:

  yum -y install  wget

2.下载mysql

  wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

3.安装mysql-community-release-el7-5.noarch.rpm包

  rpm -ivh mysql-community-release-el7-5.noarch.rpm

4.安装mysql

  yum install mysql-server

  如下图,表示安装成功

  技术图片

5.安装完毕后登录mysql修改密码

  mysql -u root

  会有如下报错

  技术图片

 

  6.把/var/lib/mysql的拥有者改为当前用户:

   sudo chown -R root:root /var/lib/mysql

  7.启动mysql: systemctl  start mysqld

   设置开机启动:systemctl enable mysqld

          systemctl daemon-reload

  8.修改密码  

    $ mysql -u root
   mysql > use mysql;
    mysql > update user set password=password(‘123456‘) where user=‘root‘;
    mysql > exit;
 9.需要更改权限才能实现远程连接MYSQL数据库
  可以通过以下方式来确认:
  root#mysql -h localhost -uroot -p
  Enter password: ******
  Welcome to the MySQL monitor.   Commands end with ; or \\g.
  Your MySQL connection id is 4 to server version: 4.0.20a-debug
  Type ‘help;’ or ‘\\h’ for help. Type ‘\\c’ to clear the buffer.
  mysql> use mysql; (此DB存放MySQL的各种配置信息)
  Database changed
  mysql> select host,user from user; (查看用户的权限情况)
  mysql> select host, user, password from user;
  +-----------+------+-------------------------------------------+
  | host      | user | password                                  |
  +-----------+------+-------------------------------------------+
  | localhost | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
  | 127.0.0.1 | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
  | localhost |      |                                           |
  +-----------+------+-------------------------------------------+
  4 rows in set (0.01 sec)
  由此可以看出,只能以localhost的主机方式访问。
  解决方法:
  mysql> Grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant option;
  (%表示是所有的外部机器,如果指定某一台机,就将%改为相应的机器名;‘root’则是指要使用的用户名,)
  mysql> flush privileges;   (运行此句才生效,或者重启MySQL)
  Query OK, 0 rows affected (0.03 sec)
  再次查看。。
  mysql> select host, user, password from user;
  +-----------+------+-------------------------------------------+
  | host      | user | password                                  |
  +-----------+------+-------------------------------------------+
  | localhost | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
  | 127.0.0.1 | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
  | localhost |      |                                           |
  | %         | root | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
  +-----------+------+-------------------------------------------+
  4 rows in set (0.01 sec)
10.用第三方软件测试连接技术图片
      技术图片

 


    
 

 

 


      

  

 

 

以上是关于centos7下使用wget命令安装mysql的主要内容,如果未能解决你的问题,请参考以下文章

如何在Centos7下安装MySQL5.7

Centos7.x下安装MySQL5.7(yum安装)

centos7.5 安装mysql8.0

centos7在线安装mysql8.0.16

CentOS7 Hive2.3.9 安装部署(mysql 8.0)

CentOS7 Hive2.3.9 安装部署(mysql 8.0)