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

我与影子孤独终老i 提交于 2019-11-26 14:38:56

问题


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:

error

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

how to resolve my problem?


回答1:


Use the IP instead:

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):

mysqladmin -u root password 'mynewpassword'

Documentation, and Lost root access in MySQL.




回答2:


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

$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

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:

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

This way you have your root password set.




回答3:


Use this in your my.ini under

[mysqldump]
    user=root
    password=anything


来源:https://stackoverflow.com/questions/1878458/1130-host-localhost-is-not-allowed-to-connect-to-this-mysql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!