说明
以下全部操作在root
用户下完成
1. 下载安装mysql yum 源
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum install -y mysql57-community-release-el7-10.noarch.rpm
2. 安装mysql并启动
yum install -y mysql-community-server #安装mysql
systemctl start mysqld.service #启动
systemctl status mysqld.service #查看运行状态
3. 登录mysql
grep "password" /var/log/mysqld.log #查看mysql生成的密码
mysql -uroot -p #以root用户登录mysql
4. 修改root密码
注: mysql> 为提示符;新密码需符合:包含字母大小写、特殊符和数字,且位数大于4
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
5. 授权root用户远程访问
mysql> use mysql;
mysql> grant all privileges on *.* to root@'%' identified by "password";
mysql> flush privileges;