使用Navicat連接MySQL數(shù)據(jù)庫(kù)報(bào): 2003 can't connect to MySQL server on 'localhost'(10038)
解決方案:
登錄mysql數(shù)據(jù)庫(kù),查看用戶情況
mysql>? SELECT User, Host FROM mysql.user;
2.需要通過(guò)命令開啟遠(yuǎn)程訪問(wèn)權(quán)限
注意:mysql8.0 命令不需要加 IDENTIFIED BY 'password'
mysql> grant all privileges on *.*? to? 'root'@'%' with grant option;
3.修改過(guò)后如果還連不上闻丑,需要開啟端口3306
在命令行輸入firewall-cmd --query-port=3306/tcp 如果顯示的是no近尚,那么需要讓防火墻開啟3306端口
1).開啟端口3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent
2).重啟防火墻
firewall-cmd --reload
3).查看已經(jīng)開放的端口
firewall-cmd --list-ports
4.完成以上步驟,Navicat可以正常連接mysql數(shù)據(jù)庫(kù)