MySQL change root password under Linux

Source: Internet
Author: User

Method One: Use the Set password command

First, log in to MySQL

Mysql-uroot-p

Then execute the Set password command

Set password 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

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

Mysql-uroot-p

Then manipulate the user table of the MySQL library to update
mysql> use mysql;mysql> Update user set Password=password (' 654321 ') where user= ' root ' and host= ' localhost '; mysql& Gt Flush privileges;


Method Four: In case of forgetting the password

First stop the MySQL service

Service Mysqld Stop

Start MySQL in a way that bypasses authorization

Mysqld_safe--skip-grant-tables &

Log in as root user MySQL

Mysql-u Root

Manipulate the user table of the MySQL library to update

mysql> use mysql;mysql> Update user set Password=password (' 654321 ') where user= ' root ' and host= ' localhost '; mysql& Gt Flush Privileges;mysql> Quit

Restart MySQL Service

Service mysqld Restart

MySQL change root password under Linux

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.