Centos7.2下如何使用YUM來快速安裝MySQL5.7的方法介紹

這篇文章主要介紹了centos7.2下使用yum快速5.7的方法,需要的朋友可以參考下

卸載系統自帶mariadb數據庫

#?rpm?-qa|?grep?mariadb  #?rpm?-e?--nodeps?mariadb-libs-5.5.44-2.el7.centos.x86_64

下載YUM庫

#?rpm?wgethttp://dev.MySQL.com/get/mysql57-community-release-el7-7.noarch.rpm

安裝YUM庫

#?rpm?yum?localinstall?-ymysql57-community-release-el7-7.noarch.rpm

安裝數據庫

#?rpm?yum?install?-y?mysql-community-server

啟動MySQL服務

#?rpm?systemctl?start?mysqld.service

由于mysql5.7會自動生成密碼,密碼文件存儲在/var/log/mysqld.log 中passw關鍵字即可找到密碼,登陸mysql

#?mysql?-uroot?-p

重置root用戶密碼

mysql?>?alter?user?'root'@'localhost'?identified?by?'密碼';

重新以root用戶和剛設置的密碼進行登錄即可。并授權用戶root使用密碼從任何主機連接到mysql服務器

mysql?>?grant?all?privileges?on?*.*?to?'root'@'%'?identifiedby?'密碼'?with?grant?option;  mysql?>?flush?privileges;

或允許用戶root只能從ip為192.168.1.1的主機連接到mysql服務器

mysql?>?grant?all?privileges?on?*.*?to?'root'@'192.168.1.1'?identified?by?'密碼'?with?grant?option;  mysql?>?flush?privileges;

開啟3306端口

#?firewall-cmd?--add-port=3306/tcp

? 版權聲明
THE END
喜歡就支持一下吧
點贊7 分享