8

How can I change the root password to an empty one in MySql?

The following gives "Access denied for user 'root'@'localhost' (using password: YES)" error. I'm sure I've typed my password correct (it's only 123456)

mysqladmin -u root -p'123456' password ''

I've run this sql successfully but I can still access with my password 123456 and not with an empty one:

use mysql; update user set password=PASSWORD("") where User='root';
OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
dstr
  • 8,362
  • 12
  • 66
  • 106
  • The query resets the password to "" and as you have logged in successfully with password '' one could assume that you have an empty password. Set the passwort run the query specifying a password: `PASSWORD("mypassword")`. If this is what you done edit the post to make it clear. And see the answers below. – AxelEckenberger Feb 25 '10 at 17:26

2 Answers2

6

You should restart the MySQL server or run the following command:

FLUSH PRIVILEGES;

MySQL doesn't immediately "see" the changes you make to the tables containing user account data, hence the need for this additional step.

pako
  • 1,908
  • 4
  • 24
  • 40
4

You need to FLUSH PRIVILEGES.

soulmerge
  • 73,842
  • 19
  • 118
  • 155