#1130 - 不允许主机 'localhost' 连接到这个 MySQL 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2547855/
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
#1130 - Host ‘localhost’ is not allowed to connect to this MySQL server
提问by Raph
I accidentally changed the "host" value for the root user inside of the user table for mysql.
我不小心更改了 mysql 用户表中 root 用户的“主机”值。
I need to change it back to localhost because I changed it to arancillary2125 (my other machines DNS name) but I cannot access mysql (from PHPMYADMIN or command prompt) due to "localhost" not having permissions any more.
我需要将它改回 localhost,因为我将它改成了 arancillary2125(我的其他机器 DNS 名称),但由于“localhost”不再具有权限,我无法访问 mysql(从 PHPMYADMIN 或命令提示符)。
I am running windows XP // apache //
我正在运行 Windows XP // apache //
I have tried the following solutions but they didn't work:
我尝试了以下解决方案,但没有奏效:
回答by bdl
Whoops.
哎呀。
This is on your local machine, I assume? At Start->Run, enter 'services.msc' and locate the MySQL service. Stop the service.
这是在你的本地机器上,我猜?在“开始”->“运行”中,输入“services.msc”并找到 MySQL 服务。停止服务。
Edit:
编辑:
Find your my.ini file (usually in C:\Windows or C:\mysql, etc). If you don't have one, create one. It's just a plain ASCII file.
找到您的 my.ini 文件(通常在 C:\Windows 或 C:\mysql 等中)。如果没有,请创建一个。它只是一个普通的 ASCII 文件。
Alter the file, add this in the [mysqld] section: skip-grant-tables
.
更改文件中的[mysqld]部分补充一点:skip-grant-tables
。
On the command line, issue the command net start MySQL
and wait a moment, the MySQL service should start.
在命令行上,发出命令net start MySQL
并稍等片刻,MySQL 服务应该会启动。
Still on the command line, issue the command mysql -u root
and hit "ENTER". You should be logged into MySQL as the 'root' user. Carefullychange your grants and then logout. Stop the MySQL service / server. Re-edit your my.ini file and remove / comment out the skip-grant-tables
line, and again start the server. Try to login as root again.
仍然在命令行上,发出命令mysql -u root
并点击“ENTER”。您应该以“root”用户身份登录 MySQL。小心地更改您的授权,然后注销。停止 MySQL 服务/服务器。重新编辑 my.ini 文件并删除/注释掉该skip-grant-tables
行,然后再次启动服务器。尝试再次以 root 身份登录。
Just tested this on my Win XP Pro box.
刚刚在我的 Win XP Pro 盒子上测试了这个。
This essentially has the effect of bypassing all the grant tables and thus doesn't bother to lookup whether you're supposed to access it from that machine or not.
这基本上具有绕过所有授权表的效果,因此无需费心查找您是否应该从该机器访问它。
MySQL reference manual : --skip-grant-tables option
MySQL 参考手册:-- skip-grant-tables 选项
回答by Silkutz
So I had this problem aswell, happened all of a sudden with #1130 - Host ‘localhost' is not allowed to connect to this MySQL server.
所以我也遇到了这个问题,突然发生在 #1130 - Host 'localhost' is not allowed to connect to this MySQL server.
After searching and searching I can tell you that bdl solution is the way forward, once you can log back into the server you can change the permissions about and remove the line skip-grant-tables under your my.ini mysql config file.
在搜索和搜索之后,我可以告诉您 bdl 解决方案是前进的方向,一旦您可以重新登录到服务器,您就可以更改有关权限并删除 my.ini mysql 配置文件下的 skip-grant-tables 行。
I would have just upvoted bdl's post but im too new on the website to do that yet.
我本来会赞成 bdl 的帖子,但我在网站上太新了,还不能这样做。
回答by BIBD
Recreate arancillary2125 (if even on an old desk top) and then access your DB that way.
重新创建 arancillary2125(即使在旧桌面上),然后以这种方式访问您的数据库。