第一步:下载MySQL的Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
第二步:安装YumRepository
yum -y install mysql57-community-release-el7-10.noarch.rpm
第三步:安装MySQL
yum -y install mysql-community-server
第四步:启动MySQL服务
systemctl start mysqld.service
第五步:获取MySQL密码
grep "password" /var/log/mysqld.log
第六步:更新MySQL登录密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '';
第七步:设置密码的验证强度等级
set global validate_password_policy=LOW;
第八步:设置密码长度
set global validate_password_length=6;
第九步:重新设置MySQL密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
第十步:设置MySQL远程访问
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;
第十一步:防火墙添加MySQL端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent;
firewall-cmd --reload
第十二步:设置数据库字符编码(vim /etc/my.cnf)
[client]
default-character-set=utf8
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
collation-server=utf8_general_ci
service mysqld restart
status