Host is not allowed to connect to this mysql server

host主机无法访问本机的mysql服务,原因连接本机的mysql的时候,默认host是localhost,我们需要将这个mysql连接权限设置成%,更改方法直接通过软件更改和命令行更改

1.通过cmd登录mysql

2.使用mysql中的mysql表

use mysql;

3.查看host和用户

select host,user from user;

4.一般用户下的root默认的host为localhost,这里就需要将默认的host改为%,因为Host列指定了允许用户登录所使用的IP,而把Host改为%,表示所有IP都有连接权限

mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

5.一般到这一步,就可以连接上了

原文地址:https://www.cnblogs.com/yuanvblog/p/13738173.html