错误:不允许主机xxx连接到此MySQL服务器

时间:2013-10-10 06:29:54

标签: mysql database-connection

我正在尝试远程连接到MySQL服务器,如下所示:

下面的代码工作正常

mysql -u root -h localhost -p  

下面的代码返回错误

 mysql -u root -h 'server ip_address here' -p

ERROR 1130(00000):不允许主机xxx连接到此MySQL服务器

请帮忙

2 个答案:

答案 0 :(得分:18)

必须创建new MySQL User并通过phpMyAdmin或命令提示符在Query prompt中分配如下所示的权限:

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

完成所有四个查询后,它应与username / password

连接

RESTART WAMP / LAMP Server它应该有效!

答案 1 :(得分:5)

只需运行以下两个命令

GRANT ALL PRIVILEGES ON *.* TO '**YourUserName**'@'**your IP**' IDENTIFIED BY '**yourPassoword**';

flush PRIVILEGES;

,没关系,继续:)