MySQL Recover admin password

Source: Internet
Author: User
Tags administrator password

When we use MySQL may forget root password for a variety of reasons, if that is the case, the database may be discarded, but today to share the way to retrieve the root password, or if you do not know the root password to change the root password, However, it is recommended that you carefully keep the root password to prevent some unnecessary trouble to retrieve the administrator password:

[[Email protected]~]# service mysqld Stop

Shutting down MySQL .... Determine

[[Email protected]~]# vim/etc/init.d/mysqld

Approximately 283 lines:

$bindir/mysqld_safe--datadir= "$datadir"--pid-file= "$mysqld _pid_file_path" $other _args >/dev/null2>&1 &

Wait_for_pid created "$!" " $mysqld _pid_file_path "; Return_value=$?

Change to

$bindir/mysqld_safe --skip-grant-tables--skip-networking

--datadir= "$datadir"--pid-file= "$mysqld _pid_file_path" $other _args >/dev/null2>&1 &

Wait_for_pid created "$!" " $mysqld _pid_file_path "; Return_value=$?
Save exit

mysql> use MySQL

Readingtable information for completion of table and column names

You canturn off this feature to get a quicker startup with-a

Databasechanged

Mysql> select User,host,password from user;

+---------+-----------------------+-------------------------------------------+

|user | Host | password |

+---------+-----------------------+-------------------------------------------+

|root | localhost |*4941369bd46398a2bdeec85411065d7137d4ea0f |

|root | Localhost.localdomain |*4941369bd46398a2bdeec85411065d7137d4ea0f |

|root | 127.0.0.1 |*4941369bd46398a2bdeec85411065d7137d4ea0f |

|tianke | % |*a399693a49f7ec7c548d0fc376fa52ad293a552f |

|tianke1 | % |*eeac51414f1ae247d67f47a875bdb134cf39986c |

+---------+-----------------------+-------------------------------------------+

5 Rowsin Set (0.01 sec)

Change root password

mysql> Update user Setpassword=password (' 123456 ') whereuser= ' root ';

Queryok, 3 Rows Affected (0.00 sec)

Rowsmatched:3 Changed:3 warnings:0

Then stop the service again and then change the count back to restart MySQL.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MySQL Recover admin password

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.