12

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

下面的代码工作正常

mysql -u root -h localhost -p  

下面的代码给我一个错误

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

ERROR 1130 (00000): Host xxx is not allowed to connect to this MySQL server

请帮忙

4

2 回答 2

18

必须通过 phpMyAdmin 或命令提示符创建new MySQL User并分配如下权限: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它应该工作!

于 2013-10-10T06:32:18.650 回答
8

只需运行以下两个命令

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

flush PRIVILEGES;

会好的,继续:)

于 2013-10-10T06:32:37.593 回答