mysql解决无法远程客户端连接

1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
2. 授权法。例如,你想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;


我的mysql.user里root用户的host果然是localhost,先用改表法给localhost改成“%”,还是不行,仍然报1130的错 误,又按“从任何主机连接到mysql服务器”方法授权,还是报一样的错,最后给自己的ip授权之后,终于登录上了。。。。

总个全过程大致

进入Linux系统下的mysql数据库中,打开user表,找到“host”字段值为“localhost”的记录,将值“localhost”更新为“%”。 
命令如下: 
#mysql -u root -p 
Enter password: 
mysql>use mysql; 
mysql>update user set host='%' where user='root' and host='localhost'; 
mysql>select host,user from user; 

 MySQL 1130错误解决方法: 
通过MySQL-Front或MySQL administrator连接MySQL的时候发生的这个错误 

ERROR 1130: Host ***.***.***.*** is not allowed to connect to this MySQL server 


说明所连接的用户帐号没有远程连接的权限,只能在本机(localhost)登录。 
需更改 MySQL 数据库里的 user表里的 host项 
把localhost改称% 

具体步骤:登陆到MySQL 
首先 use MySQL; 
按照别人提供的方式update的时候,出现错误。 

MySQL> update user set host='%' where user = 'root'; 
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 


然后查看了下数据库的host信息如下: 

MySQL> select host from user where user = 'root'; 


+-----------------------+ 
| host | 
+-----------------------+ 
| % | 
| 127.0.0.1 | 
| localhost.localdomain | 
+-----------------------+ 
3 rows in set (0.00 sec) 
host已经有了%这个值,所以直接运行命令:

MySQL>flush privileges; 
原文地址:https://www.cnblogs.com/hwaggLee/p/4639526.html