ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.48' (111)
(1)一开始我使用root用户和mysql服务器ip远程连接,直接报错:
[root@chu Record]# mysql --host=192.168.110.68 --user=root --password
Enter password:
ERROR 2003 (HY000): Can
't connect to MySQL server on '
192.168.110.68' (111)
|
原来是
默认情况下Mysql只允许本地登录,所以需要修改配置文件将地址绑定给注释掉:
vim /etc/mysql/my.cnf
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1 <---注释掉这一行就可以远程登录了
ERROR 1130 (HY000): Host '192.168.1.22' is not allowed to connect to this MySQL server
(2)修改后继续报错:
[root@chu Record]# mysql --host=192.168.110.68 --user=root --password
Enter password:
ERROR 1130 (HY000): Host '192.168.56.123' is not allowed to connect to this MySQL server
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;