1.systemctl start firewalld.service(開啓防火牆)mysql
2.systemctl stop firewalld.service(開啓防火牆)linux
3.service firewalld restart(從啓防火牆)sql
4.firewall-cmd --zone=public --add-port=4400-4600/udp --permanen(指定端口範圍爲4400-4600經過防火牆)安全
Warning: ALREADY_ENABLED: 3306:tcp(說明3306端口經過成功)服務器
5.firewall-cmd --zone=public --remove-port=80/tcp --permanent(關閉指定端口)tcp
6.firewall-cmd --zone=public --list-ports(查看經過的端口)ide
7.查看防火牆狀態 :firewall-cmd --state測試
8.修改mysql密碼:SET PASSWORD = PASSWORD('123456');網站
9.flush privileges;阿里雲
10.grant all privileges on *.* to 'root'@'%' identified by'test1234';(將所root用戶的全部ip 以密碼爲test1234登陸)
11.flush privileges
12,在10前要先執行這個:update user set host = '%' where user = 'root';
13.在8前要先 use mysql
14.如何更改了mysql端口後 從啓服務沒有反應時 執行該命令:/usr/sbin/setenforce 0 (
開啓了selinux,mysql會沒法啓動,你會在日誌中看到如下錯誤
[ERROR] Can't start server: Bind on TCP/IP port: Permission denied
[ERROR] Do you already have another mysqld server running on port: 3308
)
原文連接:https://blog.csdn.net/qq_40084534/article/details/82928401