'localhost'不允许连接到此MySQL服务器

When I tried to connect to my http://localhost/phpmyadmin the following error appeared:

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

I tried to connect to MySQL from command line and the same error appeared as well.

I used root as user, there are many suggestions that tell to do some scripts from MySQL, but I can't log in MySQL even though with root user. I have a root access but I can't log in because of that error, that error appears when I try to log in.

Screenshot of Windows terminal

You could start MySQL with the --skip-grant-tables option

service mysqld stop
mysqld_safe --skip-grant-tables &

Then allow the user you're logging in as access from localhost:

grant all on <db>.<table> to '<user>'@'localhost' identified by password('<password>')

Then start MySQL normally:

service mysqld start

Replace all the <word> placeholders above with the actual settings. If you have root access you can just log in with the root user and run the grant line.