Retrieve the root password of MySQL

Source: Internet
Author: User
Tags mysql version mysql command line

Experimental introduction: MySQL root password is missing, unable to log in. Need to reset its root password

Environment Introduction: Compiling and installing MySQL

This blog introduction to retrieve the MySQL root password is mysql based on the compilation installation, if it is a multi-instance of the MySQL root password recovery parameters and a little bit different (see below)

The main difference is the start command after stopping the MySQL service

Compiled and installed MySQL:mysqld_safe--skip-grant-tables--user=mysql &

Multi-instance MySQL:mysqld_safe--defaults-file=/data/3306/my.cnf--skip-grant-table &

In a multi-instance environment, you need to add a parameter to indicate the database that needs to change the password of the my.cnf file, after modifying the password, you can use the Killall command to kill the MYSQLD service, login to specify Mysql.sock

View MySQL version

MySQL--version

650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;border-top-width:0px; border-bottom-width:0px;border-left-width:0px;padding-top:0px; "title=" image "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/8d/54/wkiom1ix6hpqajp0aaaqd4q2xdm780.png "width=" 604 "height="/>

Stop MySQL Service

/etc/init.d/mysqld stop

650) this.width=650; "Style=" background-image:none;margin:0px;padding-left:0px;padding-right:0px; border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px; "title=" image "border=" 0 "alt = "image" src= "Http://s3.51cto.com/wyfs02/M01/8D/54/wKiom1iX6HSDzS3nAAAMs7WTPJ0885.png" width= "347" height= "38"/ >

Join the parameters to start the MySQL service

Mysqld_safe--skip-grant-tables--user=mysql &

650) this.width=650; "Style=" background-image:none;margin:0px;padding-left:0px;padding-right:0px; border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px; "title=" image "border=" 0 "alt = "image" src= "Http://s3.51cto.com/wyfs02/M01/8D/52/wKioL1iX6HTwKXWvAAAmRpJYPu0988.png" width= "630" height= "108"/ >

Enter MySQL on the command line to log in

Mysql

650) this.width=650; "Style=" background-image:none;margin:0px;padding-left:0px;padding-right:0px; border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px; "title=" image "border=" 0 "alt = "image" src= "Http://s3.51cto.com/wyfs02/M02/8D/52/wKioL1iX6HXQ4EW4AABCvzFFayU075.png" width= "623" height= "251"/ >

Executes the MySQL command, resets the MSYQL root password, and refreshes the permissions

Update Mysql.user Set Password=password ("123456") where user= ' root ' and host= ' localhost ';

Flush privileges;

650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;border-top-width:0px; border-bottom-width:0px;border-left-width:0px;padding-top:0px; "title=" image "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m00/8d/52/wkiol1ix6hbxfootaaakoq5h6hi566.png "width=" 773 "height=" 102 "/>

After the permission is executed, exit the MySQL command line via \q.

The shutdown command is required to shut down the MySQL service because it was not started by mysqld.

mysqladmin-uroot-p123456 shutdown

650) this.width=650; "Style=" background-image:none;margin:0px;padding-left:0px;padding-right:0px; border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px; "title=" image "border=" 0 "alt = "image" src= "Http://s3.51cto.com/wyfs02/M01/8D/52/wKioL1iX6HawCArTAAAb4FhOeJY815.png" width= "753" height= "60"/ >

Start the MySQL service

/etc/init.d/mysqld start

650) this.width=650; "Style=" background-image:none;margin:0px;padding-left:0px;padding-right:0px; border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px; "title=" image "border=" 0 "alt = "image" src= "Http://s3.51cto.com/wyfs02/M02/8D/54/wKiom1iX6HfTy5kwAAAL2vY2yi4964.png" width= "358" height= "36"/ >

Log in to MySQL service with the password you just changed, the password modification is successful.

mysql-uroot-p123456

650) this.width=650; "Style=" background-image:none;margin:0px;padding-left:0px;padding-right:0px; border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px; "title=" image "border=" 0 "alt = "image" src= "Http://s3.51cto.com/wyfs02/M02/8D/52/wKioL1iX6Hjjc254AABB9a7vTuA800.png" width= "640" height= "232"/ >

Ok,mysql root password has been successfully reset

This article is from the "LULU" blog, make sure to keep this source http://aby028.blog.51cto.com/5371905/1895200

Retrieve the root password of MySQL

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.