Reset the password of the MySQL database root user

Source: Internet
Author: User

in known MYSQL of the database ROOT user Password, the method of changing the password:

1. in the SHELL Environment, use the mysqladmin command settings:mysqladmin–u root–p Password " new password " enter after the old password is required

2. in the mysql> Environment , update MySQL directly with the update command data for the library user table:

Update Mysql.user Set Password=password (' new password ') where user= ' root ';

Flush privileges;

Note: MySQL statement to use a semicolon " ; " End

3. in the mysql> Environment, use the grant command to modify the root The user's authorization rights.

Grant All on * * to [e-mail protected] ' localhost ' identified by ' New Password ' ;

if you forget. MySQL of the database ROOT user's password, and how to do it? Here's how:

1. Close the currently running mysqld Service Program:servicemysqld stop(to first mysqld Add as System service)

2. Use the mysqld_safe script to start the MYSQLD service in Safe mode (without loading the authorization table)

/usr/local/mysql/bin/mysqld_safe--skip-grant-table &

3. Log in to the database with a root user with a blank password and reset the root user's password

# mysql-u Root

mysql> Update Mysql.user set Password=password (' new password ') where user= ' root ';

mysql> flush Privileges;

This article from "Liu Xiao Rabbit" blog, reproduced please contact the author!

Reset the password of the MySQL database root user

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.