Can't change MySQL password [duplicate]
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 den开发者_运维技巧ied access. So I repeat what's in the code block above, and the same thing happens.
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;
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
精彩评论