---
title: "Mysql连接报错：1130-host ... is not allowed to connect to this MySql server如何处理"
author: "kfcman"
date: "2018-10-12T16:16:04Z"
tags: []
categories: ["数据库"]
slug: "mysql-1130-host-is-not-allowed-to-connect-to-this-mysql-server"
draft: false
lastmod: "2018-10-12T16:16:04Z"
id: 2432057
url: "https://kfcman.iteye.com/blog/2432057"
---

这个问题是因为在数据库服务器中的mysql数据库中的user的表中没有权限(也可以说没有用户)，下面将记录我遇到问题的过程及解决的方法。

　　在搭建完LNMP环境后用Navicate连接出错

　　遇到这个问题首先到mysql所在的服务器上用连接进行处理

　　1、**连接服务器: mysql -u root -p**

　　**2、看当前所有数据库：show databases;**

　　**3、进入mysql数据库：use mysql;**

　　**4、查看mysql数据库中所有的表：show tables;**

　　**5、查看user表中的数据：select Host, User,Password from user;**

　　**6、修改user表中的Host:update user set Host='%' where User='root';**

　　**7、最后刷新一下：flush privileges;**

**#一定要记得在写sql的时候要在语句完成后加上" ; "下面是图示说明**

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131022661-152795230.png)

　　遇到这个问题首先到mysql所在的服务器上用连接进行处理

　　**连接服务器: mysql -u root -p**

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131318255-683574509.png)

　　**查看当前所有数据库：show databases;**

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131646286-1982836224.png)

　　**进入mysql数据库：use mysql;**

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131749724-1387433844.png)

　　**查看mysql数据库中所有的表：show tables;**

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131937958-1048454413.png)

　　**查看user表中的数据：select Host, User,Password from user;**

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005132311646-432223453.png)

　　**修改user表中的Host:update user set Host='%' where User='root';**

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005132640099-1037311838.png)

　　**最后刷新一下：flush privileges;**

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005132739865-1075208564.png)

　　重新在Navicate中测试一下：

　　![](https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005132842427-2119447116.png)

　　参考自：http://www.cnblogs.com/xyzdw/archive/2011/08/11/2135227.html；