使用navicat进行远程登录MySQL时,报出
ERROR 1130: Host '192.168.11.1' is not allowed to connect to this MySQL server
解决方法:需要修改mysql数据库下的user表user=root的host字段的值,将localhost改为%
首先在mysql安装机器上登录mysql,
>>提君博客原创 http://www.cnblogs.com/tijun/ <<
然后切换到mysql 数据库下
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> show tables
-> ;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
rows in set (0.00 sec)
查看user表中的内容
mysql> select host,user from user;
+------------+------+
| host | user |
+------------+------+
| 127.0.0.1 | root |
| localhost | |
| localhost | root |
| ltt5.bg.cn | |
| ltt5.bg.cn | root |
+------------+------+
rows in set (0.00 sec)
这里就可以看到,root用户目前只允许在localhost下登录
修改
mysql> update user set host = '%' where user = 'root';
ERROR (): Duplicate entry '%-root' for key 'PRIMARY'
mysql> flush privileges;
Query OK, rows affected (0.00 sec)
中间会报出一个ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
不用管,执行flush privileges;即可
再次查询user表
mysql> select host,user from user;
+------------+------+
| host | user |
+------------+------+
| % | root |
| 127.0.0.1 | root |
| localhost | |
| ltt5.bg.cn | |
| ltt5.bg.cn | root |
+------------+------+
rows in set (0.00 sec)
到这里,你可以在navicat上再次连接mysql,就可以成功了。
>>提君博客原创 http://www.cnblogs.com/tijun/ <<