#1130 - 不允许主机 'localhost' 连接到这个 MySQL 服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1878458/
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 14:44:31  来源:igfitidea点击:

#1130 - Host ‘localhost’ is not allowed to connect to this MySQL server

mysqldatabasephpmyadminprivilegesmysql-error-1130

提问by Steven

I issued a command of:

我发出了以下命令:

DROP USER 'root'@'localhost'; GRANT ALL PRIVILEGES ON . TO 'root'@'%';

...in PhpMyAdmin. Immediately after the execution, I was forced out PhpMyAdmin. I got:

...在 PHPMyAdmin 中。执行后,我立即被强制退出 PhpMyAdmin。我有:

error

错误

#1130 - Host 'localhost' is not allowed to connect to this MySQL server,

#1130 - 不允许主机 'localhost' 连接到这个 MySQL 服务器,

how to resolve my problem?

如何解决我的问题?

回答by OMG Ponies

Use the IP instead:

改用 IP:

DROP USER 'root'@'127.0.0.1'; GRANT ALL PRIVILEGES ON . TO 'root'@'%';

For more possibilities, see this link.

有关更多可能性,请参阅此链接

To create the root user, seeing as MySQL is local & all, execute the following from the command line (Start > Run > "cmd" without quotes):

要创建 root 用户,看到 MySQL 是本地的,请从命令行执行以下命令(开始 > 运行 > "cmd" 不带引号):

mysqladmin -u root password 'mynewpassword'

Documentation, and Lost root access in MySQL.

文档在 MySQL 中失去 root 访问权限

回答by Haitham Sweilem

Find the file "config.inc.php" under your phpMyAdmin directory and edit the following lines:

在 phpMyAdmin 目录下找到文件“config.inc.php”并编辑以下几行:

$cfg['Servers'][$i]['auth_type'] = 'config'; // config, http, cookie

$cfg['Servers'][$i]['auth_type'] = 'config'; // config, http, cookie

$cfg['Servers'][$i]['user'] = 'root'; // MySQL user

$cfg['Servers'][$i]['user'] = 'root'; // MySQL user

$cfg['Servers'][$i]['password'] = 'TYPE_YOUR_PASSWORD_HERE'; // MySQL password

$cfg['Servers'][$i]['password'] = 'TYPE_YOUR_PASSWORD_HERE'; // MySQL password

Note that the password used in the 'password' field must be the same for the MySQL root password. Also, you should check if root login is allowed in this line:

请注意,“密码”字段中使用的密码必须与 MySQL 根密码相同。此外,您应该检查此行中是否允许 root 登录:

$cfg['Servers'][$i]['AllowRoot']     = TRUE;        // true = allow root login

This way you have your root password set.

这样你就设置了 root 密码。

回答by Prathap

Use this in your my.iniunder

在你的my.ini下使用这个

[mysqldump]
    user=root
    password=anything