查看是否有mysql 的yum源
yum list | grep mysql
查看是否有mysql-server,由于某些yum源的版本。
使用yum方式安装
wget https://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-server
查看mysql是否开启
service mysqld status
如果没有开启,先开启服务
systemctl restart mysqld.service
检查是否mysql 设置了开机启动
systemctl list-unit-files|grep mysqld
进入mysql ,在任意位置输入mysql
修改mysql 用户密码
绕过密码验证 ,在 /etc/my. cnf 中添加 skip-grant-tables
重启mysql服务
systemctl restart mysqld.service
进入mysql
mysql> use mysql
mysql> update mysql.user set authentication_string=password(‘123456’) where user=‘root’;
mysql> update user set password=password(“你的新密码”) where user=“root”;
mysql> flush privileges;
mysql> quit
去掉 my.cnf 中 skip-grant-tables ,重启 MySQL
systemctl restart mysqld.service
查看存在的端口
firewall-cmd --zone=public --list-ports
添加3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent (–permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
重启mysql服务
systemctl start mysqld.service