我正在尝试远程连接到MySQL服务器,如下所示:
下面的代码工作正常
mysql -u root -h localhost -p
下面的代码返回错误
mysql -u root -h 'server ip_address here' -p
ERROR 1130(00000):不允许主机xxx连接到此MySQL服务器
请帮忙
答案 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;
,没关系,继续:)