问题描述

解决Host ‘xxx.xx.xx.xx‘ is not allowed to connect to this MySQL server_bug

一般出现这种情况说明只有 xxx.xx.xx.xx host具有root权限我们需要改成所有host。

注意:本文中采用的docker部署需进入容器中更改配置。



目录


解决方法

  1. 进入docker容器
docker exec -it 容器id bash

解决Host ‘xxx.xx.xx.xx‘ is not allowed to connect to this MySQL server_docker_02

  1. 进入mysql (未使用docker的可直接从此步骤开始)
mysql -uroot -p密码

解决Host ‘xxx.xx.xx.xx‘ is not allowed to connect to this MySQL server_docker_03

  1. 选择数据
use mysql;
  1. 修改user表中的Host
update user set Host='%' where User='root';

解决Host ‘xxx.xx.xx.xx‘ is not allowed to connect to this MySQL server_bug_04

  1. 刷新
flush privileges;

解决Host ‘xxx.xx.xx.xx‘ is not allowed to connect to this MySQL server_docker_05

  1. 退出mysql与docker容器
exit

解决Host ‘xxx.xx.xx.xx‘ is not allowed to connect to this MySQL server_bug_06


测试

上述步骤完成后,通过我们的Navicat工具进行测试。发现 连接成功!

解决Host ‘xxx.xx.xx.xx‘ is not allowed to connect to this MySQL server_bug_07