一、下載mysql的repo源mysql
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpmsql
二、安裝mysql-community-release-el7-5.noarch.rpm包tcp
rpm -ivh mysql-community-release-el7-5.noarch.rpmide
三、安裝mysqlpost
yum install mysql-serverrest
四、受權用戶能夠使用mysqlserver
chown -R root:root /var/lib/mysqlblog
五、重啓服務ip
service mysqld restartget
六、接下來登陸重置密碼:
a)、mysql -u root # 進入mysql
# 下面爲mysql命令
use mysql;
update user set password=password('123456') where user='root';
grant all privileges on *.* to 'root'@'%' identified by '123456'; # 設置遠程登錄密碼
flush privileges; # 刷新當前配置 注:若是無論用,重啓虛擬機ctrl+c,退出myql
七、開放3306端口:
設置 iptables service
yum -y install iptables-services
若是要修改防火牆配置,如增長防火牆端口3306
vi /etc/sysconfig/iptables
增長規則
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # 保存退出後
八、配置防火牆:
systemctl restart iptables.service # 重啓防火牆使配置生效
systemctl enable iptables.service # 設置防火牆開機啓動