In the MySQL password modification There are two cases, one is no password set password, this situation occurs when the first installation completed MySQL, MySQL no password, in order to secure the data, we have to set the password, the other is to completely forget the password, you need to change the forgotten password into a new password, Here I will be a demonstration of the two situations, I hope that everyone's study is helpful.
No password Set password
(PS: I installed MySQL under the/usr/src/mysql/mysql, the following situation is based on my installation path, we can according to their own habits to be good)
Format: Mysqladmin-u username-P Old password password new password
For example: User name: Root old password: blank new password: Testpassword
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4B/C5/wKiom1QysKmyqSx9AACVryVQiic943.jpg "title=" Set the password. png "alt=" wkiom1qyskmyqsx9aacvryvqiic943.jpg "/> Because there is no password, so when the following situation, directly click on the ' Enter ' key, set the completion, the next login," Enter Password: ' When the new password is entered, enter the Enter;
2. completely forgot the password
Format: Set password for ' user name ' @ ' hostname ' =password (' New password ')
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4B/CA/wKioL1QzVrSR0xFzAAC_p94hvBY852.jpg "title=" Set success 1.jpg "alt=" Wkiol1qzvrsr0xfzaac_p94hvby852.jpg "/>
Tip: The general hostname defaults to ' localhost '
Format: use MySQL;
Update user set Password=password (' 123456 ');
flush privileges; (Be sure not to forget the line, otherwise the new password will not take effect)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4B/C8/wKiom1QzWPzgkfbkAAFzjJKD64o177.jpg "title=" Set success 2.jpg "alt=" Wkiom1qzwpzgkfbkaafzjjkd64o177.jpg "/>
Format: First vi/etc/my.cnf, add skip-grant-tables (skip permission table) to [mysqld] group
Second, restart MySQL with service mysqld Restart, if this statement is already configured on your notebook, you can use
Then,/usr/src/mysql/mysql/bin/mysql (This is my MySQL installation path) into MySQL
again, Use MySQL;
Update user Set Password=password (' my ');
flush privileges; (Be sure not to forget the line, otherwise the new password will not take effect)
Finally, the words just added below [mysqld] can be deleted, restart MySQL, and then use the usual way of landing, enter the password to login.
Mysql5.5 Password modification under CentOS