MySQL forgot root password workaround

Source: Internet
Author: User


Change Password

1. Newly Installed database setup password

Mysqladmin-u Root Password 123456




2. If your root now has a password (123456), then the command to change the password to ABCdef is:

Mysqladmin-u root-p Password abcdef

Note that the command will ask you the old password, enter the old password 123456 after the command completes, the password modification succeeds.


Or

Mysqladmin-u root-p123456 Password www123




MYSQL Forgot Password Solution


Method One:

If MySQL is running, first kill it: Pkill MySQL

Start Mysql:bin/safe_mysqld--skip-grant-tables &

You can go to MySQL without a password.

Enter Mysql-uroot-p return Enter

Then there is

>use MySQL

>update User Set Password=password ("New_pass") where user= "root";

>flush privileges;


> Quit quitting

Service mysqld Restart


Mysql-uroot-p New Password entry





Method Two:

1. Edit the MySQL Master profile my.cnf

Vim/etc/my.cnf

Add a parameter under the [Mysqld] field skip-grant


2. Restart the database service

Service mysqld Restart


3. This allows access to the database without authorization.

Mysql-uroot


4. Modify the corresponding user password

Use MySQL;

Update user set Password=password (' Your password ') where user= ' root ';

Flush privileges;


5. Modify/ETC/MY.CNF remove skip-grant, restart MySQL service






This article is from the "Bill of Operations Notes" blog, please be sure to keep this source http://chenshoubiao.blog.51cto.com/6159058/1842629

MySQL forgot root password workaround

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.