mysql数据库连接报错:is not allowed to connect to this mysql server

is not allowed to connect to this MySQL server

服务器上面安装的mysql数据库在本地连接的时候报错:is not allowed to connect to this MySQL server

 

出现这种情况的原因是因为:

mysql数据库只允许自身所在的本机器连接,不允许远程连接。

解决:

在mysql所在服务器上面登录进mysql数据库中:

mysql -u root -p

mysql数据库连接报错:is not allowed to connect to this mysql server_第1张图片

进入到mysql数据库中:

use mysql;

select host from user where user='root';

 

可以看到 我们执行查询语句得到的数据结果中 host 的值是 localhost

我们执行update语句把权限进行修改

update user set host = '%' where user ='root';

 然后 刷新配置

flush privileges;

mysql数据库连接报错:is not allowed to connect to this mysql server_第2张图片

如图所示 可以看到已经修改成功

然后我们再次进行连接

 

 

你可能感兴趣的:(mysql,mysql,数据库,服务器)