美文网首页
CentOS7安装mysql8

CentOS7安装mysql8

作者: 小辉哥08 | 来源:发表于2021-06-20 06:55 被阅读0次

    1. 下载rpm文件,用于yum安装

    • 浏览器打开MySQL Yum Repository下载页
      MySQL Yum Repository.png
    • 点击Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package 右侧的【Download】下载按钮
      MySQL Community Downloads.png
    • 点击左下方链接【No thanks, just start my download】,开始下载

    2. 安装mysql8

    • 将下载好的rpm包上传到CentOS7的/tmp目录
      yum -y install /tmp/mysql80-community-release-el7-3.noarch.rpm
    • yum安装MySQL服务器
      yum -y install mysql-community-server
    • 启动MySQL服务
      systemctl start mysqld.service
    • 查看服务启动之后的状态
      systemctl status mysqld.service
      mysql service status.png
    • 找出root用户的密码
      grep "password" /var/log/mysqld.log
      mysql temporary password.png
    • 用查出来的初始密码连接数据库
      mysql -uroot -p
      enter mysql.png
    • 修改初始密码
      ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root_12root';
      SHOW VARIABLES LIKE 'validate_password%';
      validate_password.png
      set global validate_password.policy=0;
      set global validate_password.length=1;
      ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
    • 设置mysql远程连接
    mysql> use mysql;
    mysql> update user set host="%" where user='root';
    mysql> grant all privileges on test.* to root@'%';
    mysql> GRANT ALL ON *.* TO 'root'@'%';
    mysql> flush privileges;
    
    
    • 客户端连接mysql弹窗报错:
      客户端连接报错.png
    • 原因是mysql8的加密方式规则不一样,是caching_sha2_password。需要将加密方式改成mysql_native_password
    mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
    

    相关文章

      网友评论

          本文标题:CentOS7安装mysql8

          本文链接:https://www.haomeiwen.com/subject/trxoeltx.html