1130-Host '' is not allowed to connect to this mysql server
时间: 2023-09-01 17:07:07 浏览: 104
MYSQL不能从远程连接的一个解决方法(s not allowed to connect to this MySQL server)
错误信息"1130-Host '' is not allowed to connect to this mysql server"表示该主机不允许连接到 MySQL 服务器。出现这个错误的原因通常是没有为该主机授权远程访问 MySQL。
解决此问题的方法有两种:
1. 改表法:可以在 localhost 的电脑上登录 MySQL,然后更改 "mysql" 数据库中的 "user" 表中的 "host" 项,将其从 "localhost" 改为 "%"。具体操作如下:
```
mysql -u root -p
use mysql;
update user set host = '%' where user = 'root';
select host, user from user;
```
2. 授权法:使用 GRANT 语句为指定的用户授权从特定主机连接到 MySQL 服务器。例如,如果你想让用户 myuser 使用密码 mypassword 从任何主机连接到 MySQL 服务器,可以使用以下语句:
```
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
```
如果你想允许用户 myuser 从 IP 地址为 192.168.1.3 的主机连接到 MySQL 服务器,并使用 mypassword 作为密码,则可以使用以下语句:
```
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
```
通过执行上述操作,你可以解决 "1130-Host '' is not allowed to connect to this mysql server" 错误,并允许指定的主机连接到 MySQL 服务器。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [1130, "Host 'xxxx' is not allowed to connect to this MySQL server](https://blog.csdn.net/zd147896325/article/details/82427107)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Host 主机名 is not allowed to connect the mysql server](https://download.csdn.net/download/weixin_38599712/14037862)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [解决ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL server 方法](https://blog.csdn.net/xingxu0207/article/details/77870702)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文