1.下載mysql源安裝包html
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2.安裝mysql源mysql
yum localinstall mysql57-community-release-el7-8.noarch.rpm
3.檢查mysql源是否安裝成功linux
yum repolist enabled | grep "mysql.*-community.*"
4.安裝MySQLsql
yum install mysql-community-server
5.啓動MySQL服務安全
service mysqld start
等同於命令:systemctl start mysqld
重啓命令是:service mysqld restart
tcp
6.檢查mysql 的運行狀態測試
service mysqld status
7.修改root本地登陸密碼ui
7.1查看初始密碼spa
grep 'temporary password' /var/log/mysqld.log
7.2用初始密碼登陸插件
mysql -uroot -p
7.3修改初始密碼
set password for 'root'@'localhost'=password('Root@123456');
注意:mysql5.7默認安裝了密碼安全檢查插件(validate_password),默認密碼檢查策略要求密碼必須包含:大小寫字母、數字和特殊符號,而且長度不能少於8位。不然會提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements錯誤
8.受權其餘機器登錄
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Root@123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
9.防火牆開啓3306端口
sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo systemctl restart firewalld.service #重啓防火牆
查看全部開啓的端口命令:firewall-cmd --list-ports
10.測試鏈接
11.設置mysql開機啓動
systemctl enable mysqld
12.mysql文件目錄systemctl daemon-reload
參考文檔:
https://www.linuxidc.com/Linux/2016-09/135288.htm
https://www.cnblogs.com/jimboi/p/6405560.html
https://www.cnblogs.com/silentdoer/articles/7258232.html