1

I installed MySQL, and the installation requires a password. I didn't want to enter one, but I had to to click "Next" and finish the installation.

So, I tried to change it.

In the cmd prompt:

C:\>mysql -u root -p
Enter password: **

mysql> use mysql;
Database changed
mysql> select `password` from `user` where `user` = 'root';

That returns an empty password field. But when I do mysql -u root I get the access denied error, and then I do mysql -u root -p and it asks for a password, I press enter, and I get denied access. So I repeat what's in the code block above, and the same thing happens.

Andrew
  • 12,172
  • 16
  • 46
  • 61
  • you're saying you can't log in, but your code block shows you logging in. how did you log in to look at the password? – longneck Dec 15 '09 at 22:10
  • Entering the password that I had to create to install MySQL. My problem is that I can't change it. – Andrew Dec 15 '09 at 23:12

2 Answers2

3

According to MySQL's documentation on How to Reset the Root Password:

UPDATE mysql.user SET password=PASSWORD("my-new-password") WHERE User='root';
FLUSH PRIVILEGES;
jww
  • 97,681
  • 90
  • 411
  • 885
syncerror
  • 131
  • 1
  • 10
2

Try this

In your command prompt, Type the following : mysqladmin -u root (assuming that ur username is "root") Hit enter button, then it will show you commands to execute some stuffs. for password change Type the following ;

mysqladmin -u root password It will then ask for new password Enter ur new password , that is, the password you wish to use. Hit enter, it will request it again. Enter it and hit enter.

That is it, your password is changed Now you can check the status Type:

mysqladmin -u root -p status

It says, enter password , Use your new password

I hope it helps