連接mysql數據庫報錯解決方法
1.mysql 錯誤 ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost'
www.2cto.com
解決辦法:關閉防火牆,linux下命令
[root@etl01 bin]# chkconfig --list | grep -i iptables ====check fire wall
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@etl01 bin]# /sbin/service iptables stop ====stop fire wall
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: nat filter [ OK ]
Unloading iptables modules: [ OK ]
2.報錯:1130-host ... is not allowed to connect to this MySql server
解決辦法:
授權形式
比如賬戶為root,密碼為root
use mysql;
用root賬戶從任何主機上訪問mysql數據庫了
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
如果你想允許用戶zz從ip為192.168.1.3的主機連接到mysql服務器,並使用123456作為密碼
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.3' IDENTIFIED BY '123456' WITH GRANT OPTION;