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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19288606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:06:13  来源:igfitidea点击:

Error: Host xxx is not allowed to connect to this MySQL server

mysqldatabase-connection

提问by Aditya P Bhatt

I'm trying to connect remotely to MySQL server as following:

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

below code works fine

下面的代码工作正常

mysql -u root -h localhost -p  

below code returns me an error

下面的代码返回一个错误

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

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

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

Please help

请帮忙

回答by Aditya P Bhatt

One has to create a new MySQL Userand assign privileges as below in Query promptvia phpMyAdmin or command prompt:

必须通过 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;

Once done with all four queries, it should connect with username / password

完成所有四个查询后,它应该连接 username / password

RESTART WAMP / LAMP Serverand it should work !

RESTART WAMP / LAMP Server它应该工作!

回答by Chair

Simply run de two commands below

只需运行下面的两个命令

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

flush PRIVILEGES;

and It will be fine, go on :)

会没事的,继续:)