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 an error #1130 - Host 'localhost' is not allowed to connect to this MySQL server, how to resolve my problem?

link|improve this question
Do you have any important information in this database installation? – dlo Dec 10 '09 at 3:54
Yes, I have many tables. – Steven Dec 10 '09 at 13:56
feedback

3 Answers

Open up a terminal.

$ mysql -u root --host=127.0.0.1 -p<yourpassword>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 521
Server version: 5.1.38yes-debug yes

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE USER 'root'@'localhost' IDENTIFIED BY "<yourpassword>";
Query OK, 0 rows affected (0.22 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost;
Query OK, 0 rows affected (0.08 sec)

This should fix your problem ;).

link|improve this answer
feedback

mysql treats % and localhost differently. You need grant all privileges to 'root'@'localhost' as well.

link|improve this answer
feedback

Combine dlo's answer with Darren Chamberlain's. The reason for this is that the special meaning that 'localhost' has in MySQL is that it signifies to use the local unix socket (mysql.sock) vs the TCP socket. This is why specifying 127.0.0.1 as the host will get you in so that you can fix the situation; it signifies to the MySQL client to use the TCP socket.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown