Centos7yum安装mysql5.7

1、安装MySQL和官方 Yum源

    wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7- 10.noarch.rpm

    yum -y install mysql57-community-release-el7-10.noarch.rpm mysql-community-server

2、启动数据库并设置开机自启动

    systemctl start mysqld

    systemctl enable mysqld

3、查看数据库密码并登陆数据库

    grep "password" /var/log/mysqld.log

    2019-07-18T10:27:59.058559Z 1 [Note] A temporary password is generated for root@localhost: x8w4o

4、登陆数据库修改密码

    mysql -uroot -p

    mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

    mysql>flush privileges;

5、设置远程用户登录数据库权限

    mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'newpassword'

    mysql>flush privileges;

    

你可能感兴趣的:(Centos7yum安装mysql5.7)