-1

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

halfer
  • 19,824
  • 17
  • 99
  • 186
Aladdin
  • 1,207
  • 2
  • 16
  • 26
  • Seems like a very clear answer to your problem. You cannot connect to the database you're trying to connect with. – Refilon Feb 20 '15 at 14:24
  • Show your mysql.users table. – Tomas M Feb 20 '15 at 14:25
  • 2
    possible duplicate of [Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server](http://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server) –  Feb 20 '15 at 14:25
  • If you have root access, you can reset the permissions this user has to access the database. – halfer Feb 20 '15 at 14:28
  • possible duplicate of [#1130 - Host ‘localhost’ is not allowed to connect to this MySQL server](http://stackoverflow.com/questions/1878458/1130-host-localhost-is-not-allowed-to-connect-to-this-mysql-server) –  Feb 20 '15 at 14:28
  • @halfer how I can do that? actually I have the root access. – Aladdin Feb 20 '15 at 17:09
  • Use the `CREATE USER` syntax, [docs are here](https://dev.mysql.com/doc/refman/5.6/en/adding-users.html). Log on a root (or another administrator user) to do so. – halfer Feb 20 '15 at 17:38
  • I have a root access but I can't log in because of that error. That error appears when I try to log in. – Aladdin Feb 20 '15 at 20:16
  • You can't log in as root either? To be absolutely clear, are you saying that MySQL has locked you out completely? I don't think it is possible to do that to the root account, but please clarify. – halfer Feb 20 '15 at 20:47
  • (If you are replying to someone, then use their handle e.g. @halfer for me, otherwise your response will likely be missed). – halfer Feb 20 '15 at 20:48
  • A couple of things to try: use `127.0.0.1` instead of `localhost`, that might work. Also, do a search for "start MySQL without root password" to create a new user account. I think you might have deleted the root user, and need to reset it. – halfer Mar 24 '15 at 12:41

1 Answers1

1

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
DavidC
  • 11
  • 1