报错:1130-host ... is not allowed to connect to this MySql server 开放mysql远程连接 不使用localhost

来源:互联网 发布:7.0wow mac 插件 编辑:程序博客网 时间:2024/06/06 00:25

MySQL服务器的远程链接设置有两种方法:

一、改表法。

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

a. bin/mysql -uroot-p密码

b. usemysql----->showtables;------>select host, user fromuser;

c. updateuser set host = '%' where user = 'root';

ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 不予理会

d. flush  privileges;


二、授权法。

例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALLPRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITHGRANT OPTION;

如果你想允许用户qikaiip172.22.254.1的主机连接到mysql服务器,并使用123456作为密码 .

GRANT ALLPRIVILEGES ON *.* TO 'qikai'@'172.22.254.1' IDENTIFIED BY'123456' WITH GRANT OPTION;

阅读全文
0 0