CentOS 7.6安装MySQL8

发布时间 2023-09-15 16:36:25作者: lsepi
  • 下载yum源

    wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
    
  • 安装yum源

    rpm -ivh mysql80-community-release-el7-5.noarch.rpm
    
  • 安装MySQL

    yum install -y mysql-server
    
  • 启动mysql服务

    systemctl start mysqld
    
  • 查看root临时密码

    grep 'temporary password' /var/log/mysqld.log
    
  • 登录mysql

    mysql -uroot -p
    
  • 修改密码

    alter user 'root'@'localhost' identified by 'root的密码';
    
  • 开启远程登录

    use mysql ;
    update user set host = '%' where user = 'root';
    FLUSH PRIVILEGES;
    
  • 重启数据库

    service mysqld restart
    或
    systemctl restart mysqld