1.安装mysql57
yum install -y wget
wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
// 启动MySQL
systemctl start mysqld.service
// 查看运行状态
systemctl status mysqld.service
// 找到root用户密码,在日志文件中找到密码
以下两条命令二选其一:
grep “password” /var/log/mysqld.log
grep -Eo “for root@localhost:.*” /var/log/mysqld.log | sed -r “s/(for.localhost: )(.)/\2/”
// 进入mysql
mysql -uroot -p
// 设置MySQL的密码长度
set global validate_password_policy=0;
set global validate_password_length=1;
// 设置新密码
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘admin@123’;
//进入mysql数据库,并设置内网登录,刷新数据库,退出;
use mysql;
update user set host=’%’ where user=‘root’ LIMIT 1;
flush privileges;
exit
//内网登陆
mysql -h 数据库网站ip -uroot -p