Lambasoft
Lambasoft

Reputation: 999

#1130 - Host 'localhost' is not allowed to connect to this MySQL server - After running an Acunetix scan

I know this type of question has been asked lots of times, but none answer my problem. Please read carefully.

I was running my website on localhost using Wamp server normally. When today i decided to run an Acunetix scan for vulnerabilities on my localhost server.

Acunetix sent tons of commands to the mysql table in short period of time ( since it's localhost the commands went fast ) which cause my mysql server to crash with the error:

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

What I've already tried:

Running mysql through mysqld --skip-grant-tables I had access to mysql while on that, so I tried running

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

But I got the error:

mysql> DROP USER 'root'@'127.0.0.1'; GRANT ALL PRIVILEGES ON . TO 'root'@'%';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables opt
ion so it cannot execute this statement
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'TO 'r
oot'@'%'' at line 1

I admit I do am a mysql noob but I did my homeworks and searched google, but was unable to find the solution.

Any help ?

I managed ti fix the issue by reinstalling wamp server and fully uninstalling, even with the mysql.

Upvotes: 21

Views: 94550

Answers (6)

Muhammad
Muhammad

Reputation: 7324

A simple Illustrated solution!

enter image description here

⚠️ Not recommended in production, its insecure.

Upvotes: 54

Nazmul Hoque
Nazmul Hoque

Reputation: 970

  1. Click on config show in image
  2. Click my.ini show in image
  3. add skip-grant-tables after [mysqld] and save show in image. (*edited spelling issue here)
  4. Now restart mySQL. that's all

enter image description here

Upvotes: 3

theshinylight
theshinylight

Reputation: 252

I solved the issue by reinstalling the server. The new configuration (my.ini) does not contain the --skip-grant-tables option and I am able to connect to the server as expected.

Don't forget to backup your databases before you do the new installation.

Upvotes: 0

Bhuvana Prakash
Bhuvana Prakash

Reputation: 101

I had the same issue.

You can add skip-grant-tables to the my.ini file for the [mysqld] tag, under # The MySQL server, and restart the mysql server.

You can now open phpmyadmin and go to the user table in the mysql database. Make sure that the value of the password attribute is empty and that the value of host attribute is localhost. I was facing the second error. PHPMyAdmin was trying to connect with host value as 'localhost' and the table contained the value 127.0.0.1.

Remove skip-grant-tables from my.ini and restart the mysql server. This should work.

Upvotes: 10

Marc Delisle
Marc Delisle

Reputation: 8997

When your server is running with --skip-grant-tables, you disable all MySQL security so you're not allowed GRANT commands. What you can do, is access the "mysql" database and directly SELECT and UPDATE the rows you need to change. In your case it will be the user table.

Upvotes: 8

echo_Me
echo_Me

Reputation: 37253

     GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1';

http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

EDIT.

this because your mysql server is on read_only option. to turn it off

connect to the server with root user:

mysql-h localhost-u root-p

and run the command:

mysql> set GLOBAL read_only = false;

mysql> FLUSH TABLES WITH READ LOCK;
mysql> UNLOCK TABLES;

EDIT2;

you must have stop the server and run this

mysqld_safe --skip-grant-tables due to root pwd chg

so stop the server and start it normal with a start

Upvotes: 3

Related Questions