rpm -qa | grep mysql

空的话就没有,存在的话把原有的卸载,安装你想要安装的版本,避免安装冲突
//卸载MySQL
rpm -e --nodeps 后面加上MySQL信息
yum install wget -y

wget dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

yum install mysql-community-release-el7-5.noarch.rpm -y

yum install mysql-community-server -y

到此MySQL就安装好了。
systemctl start mysqld.service
查看一下启动状态
systemctl status mysqld.service

chkconfig mysqld on
grep "password" /var/log/mysqld.log
mysql -uroot -p
use mysql;
update mysql.user set password=password('123456') where user='root';

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;

进入到配置文件
vi /etc/my.cnf
# 配置默认编码为utf8
character_set_server=utf8
init_connect='SET NAMES utf8'

systemctl restart mysqld.service

# 查询3306端口是否开放
sudo firewall-cmd --zone=public --query-port=3306/tcp
# 开放3306端口
sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
# 重启防火墙,生效配置
sudo firewall-cmd --reload
