---
title: "MYSQL ERROR 1130: Host  is not allowed to connect to this MySQL server错误解决"
author: "squirrelRao"
date: "2012-03-20T17:35:43Z"
tags: []
categories: ["数据库"]
slug: "mysql-error-1130-host-is-not-allowed-to-connect-to-this-mysql-server"
draft: false
lastmod: "2012-03-20T17:36:42Z"
id: 1458437
url: "https://squirrelrao.iteye.com/blog/1458437"
---

**E** **RROR 1130: Host 'XXXXXX' is not allowed to connect to this MySQL server**

错误的解决方法：

 

**方法一：**

执行命令：

```
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
```

 

 

说明：

 

输入这段指令并回车后允许所有用root用户并且输入“123456”密码的主机登入该mysql Server

 

如果将'%'换成一个IP地址的话，那么只有该具有该IP地址的主机可以以root connect 到MYSQL Server.

 

**方法二：**

执行命令：

```
mysql> use mysql;

mysql> update user set host = '%' where user = 'root';
```

 

说明：

 

更改 "mysql" 数据库中"user" 表里的 "host" 项，将"localhost"值改为"%"