一、下载安装Yum Repository
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
yum -y install mysql-community-server
安装时报错,All matches were filtered out by modular filtering for argument: mysql-community-server
Error: Unable to find a match: mysql-community-server
解决办法:先执行 yum module disable mysql,然后再执行yum -y install mysql-community-server
二、 MySQL数据库设置
2.1 启动MySQL
systemctl start mysqld.service
2.2 查看MySQL运行状态
systemctl status mysqld.service
2.3 找出root用户的密码
grep "password" /var/log/mysqld.log
2.4 进入数据库
mysql -uroot -p
2.5 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
MySQL完整的初始密码规则可以通过如下命令查看:
SHOW VARIABLES LIKE 'validate_password%';
密码的长度是由validate_password_length决定的,而validate_password_length的计算公式是:
validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)
修改命令:
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
因为安装了Yum Repository,以后每次yum操作都会自动更新,需要卸载:
yum -y remove mysql57-community-release-el7-10.noarch
三、网络设置
服务器开放3306端口
设置密码访问权限
mysql>grant all privileges on *.* to 'root'@'%' IDENTIFIED BY 'password';
mysql>flush privileges;