问题
刚刚安装好MySQL服务,借助Navicat使用root用户连接服务,出现该问题。
1130 - Host '192.168.100.51' is not allowed to connect to this MySQL server。
错误1130,主机192.168.100.151不被允许连接到该MySQL服务。
解决
猜测该错误与登入使用的账号有关系,账号一般是有对登入的host进行限制。
于是,先使用root账号进入mysql库中
[root@localhost ~]# mysql -u root -D mysql -pdemaxiya111
查询root用户其允许的host
mysql> select user,host from user where user = 'root';
+------+-----------+
| user | host |
+------+-----------+
| root | localhost |
+------+-----------+
1 row in set (0.00 sec)
得到的结果可以看出,root用户允许只允许本地连接,这样的话我们尝试对其绑定的地址进行更新,变成什么host都可接。
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
更新完毕后,对权限进行刷新。
注:此处不刷新的话,重启MySQL服务亦可。此处主要作用是刷新information_schema库中,user_privileges表数据。
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
这之后 重新尝试连接,发现已经没有1130错误了。
其他
- host描述通配符
%:表示任意长度的任意字符。
_:表示任意单个字符。