如果你想连接你的MySQL的时候发生这个错误:

ERROR 1130: Host '192.168.1.3' is not allowed to connect to thismysql server

远程连接MYSQL提示Host is not allowed to connect to this MySQL server

将网上的资料整理了一下


1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql"数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"

mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;

如果想关掉

mysql>use mysql;

mysql>update user set host = "localhost" where user = "root" and host= "%";

mysql>flush privileges;


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 'root'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.3' IDENTIFIED BY '1235' WITH GRANT OPTION;

撤销权限语法如下

revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:

grant all on *.* to [email protected];

revoke all on *.* from [email protected];


最后一定要 mysql>flush privileges;  

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2021-08-17
  • 2021-10-17
  • 2021-07-28
  • 2022-12-23
猜你喜欢
  • 2021-04-05
  • 2021-07-26
  • 2021-07-24
  • 2021-07-27
相关资源
相似解决方案