Modify the root password of MySQL (in Linux)

Source: Internet
Author: User

Method 1:
Root User Login System

/Usr/local/mysql/bin/mysqladmin-u root-p password New password

Enter password old password

Method 2:

Log on to the mysql database as a root user.

Mysql> update mysql. user set password = password ("new password") where User = "root ";

Mysql> flush privileges;

Mysql> quit;

What should I do if I forget the root password of mysql?

If MySQL is running, first stop the mysql process: killall mysqld

Start MySQL (abnormal startup):/usr/local/mysql/bin/mysqld_safe-skip-grant-tables &

In this way, you do not need a password to enter MySQL:/usr/local/mysql/bin/mysql-u root-p (you can press enter directly when entering the password)

Mysql> update user mysql. set password = password ("new password") where user = "root ";

Mysql> flush privileges;

Mysql> quit;

Terminate the process again: killall mysqld

Start MySQL in Normal Mode:/usr/local/mysql/bin/mysqld_safe-user = mysql &

Note:

In the update statement, the password = password ("new password") is only used to replace the three words with the password we want to set during the operation. Others are written as they are, the reason for my previous failure was that the parentheses and the previous password were omitted. their role is to store passwords in the database in encrypted form.

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.