Linux forgot password/change password

Source: Internet
Author: User

Method One: Use the Set password command

First, log in to MySQL

?
1 mysql -u root -p

Then execute the Set password command

?
1 setpassword for[email protected] = password(‘654321‘);

In the example above, change the root password to 654321

Method Two: Use Mysqladmin

Format: Mysqladmin-u username-P Old password password new password

?
1 mysqladmin -uroot -p123456 password"654321"

In the example above, change the root password from 123456 to 654321

Method Three: Change the user table for MySQL

First, log in to MySQL

?
1 mysql -uroot -p

Then manipulate the user table of the MySQL library to update

?
123 mysql> use MySQL; mysql> update user set password = password ( ' 654321 ' where user = ' root ' and host= ' localhost ' mysql> flush privileges

Method Four: In case of forgetting the password

First stop the MySQL service

?
1 service mysqld stop

Start MySQL in a way that bypasses authorization

?
1 mysqld_safe --skip-grant-tables &

Log in as root user MySQL

?
1 mysql -u root

Manipulate the user table of the MySQL library to update

?
1234 mysql> use mysql;mysql> updateuser set password=password(‘654321‘) where user=‘root‘ andhost=‘localhost‘;mysql> flush privileges;mysql> quit

Restart MySQL Service

?
1 service mysqld restart

 

Linux forgot password/change password

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.