Mysql5.5 Password modification under CentOS

Source: Internet
Author: User

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.

    1. 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

    • Landed in MySQL, but suddenly confused, forgotten the password, a way:

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 '

    • Another way:

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 "/>

    • Haven't logged in yet, totally forgot your password.

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.