Linux下Mysql常見連線錯誤
阿新 • • 發佈:2019-01-01
遇到這些問題,網上很多解決方案,一搜就有。在這我簡單總結下
第一個:ERROR 2003 (HY000): Can't connect to MySQL server on '172.29.*.*' (113)
無法連線,可能有幾個原因:
1、防火牆,看下iptables
2、配置檔案中綁定了ip,檢查bind adderss (my.cnf)
3、配置檔案中skip-networking
第二個:ERROR 1130 (HY000): Host '192.168.*.*' is not allowed to connect to this MySQL server
在遠端連線時候出現,因為沒有許可權。
可以使用下面語句給予許可權:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.*.*' IDENTIFIED BY '1234' WITH GRANT OPTION;
其中192.168.*.*是本地ip,root和1234是允許的登入名和密碼,這麼連線就安全多了。
如果不限制ip,用%表示所有。
第三個:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
是因為忘記密碼了。。
最簡單方式:/etc/mysql/my.cnf 或/etc/my.cnf
加入skip-grant-tables
重啟mysql服務:service mysqld restart
可以直接進入:mysql -u root
執行改密碼:update user set password('password') where user = 'root';
把my.cnf中的skip-grant-tables去掉,重啟服務