客户端连接报错

这个问题是因为用户在数据库服务器中的mysql数据库中的user的表中没有权限。

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

解决步骤

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

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

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

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

3、进入mysql数据库:use mysql;

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

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

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

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

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

上面localhost表示只允许本地连接,不能远程连接

6、修改user表中的Host

%表示开启远程连接,且没有限制,在任何主机都可以登录;(%不包含localhost

update user set Host='%' where User='root' and Host="localhost";,但是会出现下面的问题,最好是新增一行Host为%的数据,方式参考:https://www.cnblogs.com/uncleyong/p/10931195.html

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

上面这样改了后,会导致xshell连接看不到所有的数据库(xshell表示本地连接,因为xshell先连接到服务器,然后在服务器登录数据库),localhost才表示本地连接(注意:上面localhost没有设置密码,所以本地连接,就不用密码;navicat表示远程连接,需要密码),参考:https://www.cnblogs.com/uncleyong/p/10931195.html

7、最后刷新一下:flush privileges;

 centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

8、重新在Navicate中测试一下:

centos7中,mysql连接报错:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

 

 

至此,问题解决。

相关文章:

  • 2021-06-05
  • 2021-04-03
  • 2022-01-14
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-26
  • 2021-10-10
  • 2022-12-23
  • 2021-06-11
  • 2021-09-27
  • 2021-10-14
相关资源
相似解决方案