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

时间:2009-12-10 03:25:49

标签: mysql database phpmyadmin privileges mysql-error-1130

我发出了一个命令:

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

...在PhpMyAdmin中。执行后,我立即被迫退出PhpMyAdmin。我得到了:

错误

  

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

如何解决我的问题?

3 个答案:

答案 0 :(得分:7)

改用IP:

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

有关更多可能性,请参阅this link

要创建root用户,请将MySQL视为本地& all,从命令行执行以下操作(开始>运行>“cmd”,不带引号):

mysqladmin -u root password 'mynewpassword'

DocumentationLost root access in MySQL

答案 1 :(得分:0)

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

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

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

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

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

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

这样就可以设置root密码了。

答案 2 :(得分:-1)

my.ini

下使用此功能
[mysqldump]
    user=root
    password=anything