Completely locked out of MySQL!

Viewed 14223

I've somehow managed to completely lock myself out of MySQL on WAMP. It seems all privileges are denied for all users. The only way I can get into MySQL is via the command prompt but without entering a user. From there, I quite literally cannot do anything... all privileges are denied. I've tried updating the root password to no avail.

I've also tried completely uninstalling WAMP as well as MySQL. After uninstalling MySQL, I deleted the data directories inside them to get rid of all the info there. After re-installing WAMP, the problem persists.

Attempts to access PHPMyAdmin results in:

#1045 - Access denied for user 'root'@'localhost' (using password: NO) 

Can anyone help??

EDIT Why are people voting to close this post...?

EDIT2 A wild secondary problem appears! What do you want to do? Answer or navigate away?

5 Answers

Just spent forever on this.. so many solutions did not work. Finally this worked for me.

Restart MySQL with skip-grant-tables, which bypasses security, and now you can log in and run:

USE mysql;
CHECK TABLE user;
REPAIR TABLE user;

Apparently I had corrupted users or something.. and this resolved it. After this, I found I no longer had a root user. So I had to add with the following command (being in with skip-grant-tables):

INSERT INTO mysql.user 
SET user = 'root', 
host = 'localhost', 
password = Password('yournewrootpw'), 
Select_priv = 'Y',
Insert_priv = 'Y',
Update_priv = 'Y',
Delete_priv = 'Y',
Create_priv = 'Y',
Drop_priv = 'Y',
Reload_priv = 'Y',
Shutdown_priv = 'Y',
Process_priv = 'Y',
File_priv = 'Y',
Grant_priv = 'Y',
References_priv = 'Y',
Index_priv = 'Y',
Alter_priv = 'Y',
Show_db_priv = 'Y',
Super_priv = 'Y',
Create_tmp_table_priv = 'Y',
Lock_tables_priv = 'Y',
Execute_priv = 'Y',
Repl_slave_priv = 'Y',
Repl_client_priv = 'Y',
Create_view_priv = 'Y',
Show_view_priv = 'Y',
Create_routine_priv = 'Y',
Alter_routine_priv = 'Y',
Create_user_priv = 'Y',
Event_priv = 'Y',
Trigger_priv = 'Y',
Create_tablespace_priv = 'Y';

Hopefully this saves someone else a bunch of time..

Related