在使用Navicat Premium等连接数据库时,有时会出现如下报错:
Host‘0.0.0.0’ is not allowed to connect to this MySQL server的报错框
大致表示在使用Navicat Premium的本地IP地址,不允许被连接到远程的MySQL数据库服务
如果本地电脑IP地址可以正常连接其它数据库服务器操作。
则解决办法如下:
1、首先利用Xshell等连接工具登陆远程MySQL数据库的服务器
2、在服务器上登陆MySQL
root@wangting:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
3、进入系统库里查询一下连入规则
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select t.host from user t where t.user='root';
+-----------+
| host |
+-----------+
| localhost |
+-----------+
1 row in set (0.00 sec)
发现连入的规则只能是本地接入,一般对外接受应该是 %
4、修改规则,并重启MySQL server的服务;之后即可远程正常连入数据库不被阻拦。
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> exit
Bye
root@wangting:~# /etc/init.d/mysql restart
[ ok ] Restarting mysql (via systemctl): mysql.service.
OK,问题解决
再附上修改规则后的反馈结果(不再是localhost):
mysql> select t.host from user t where t.user='root';
+------+
| host |
+------+
| % |
+------+
1 row in set (0.00 sec)