MySQL Root Password recovery

Source: Internet
Author: User

Take MySQL multi-instance as an example to demonstrate the password to retrieve MySQL root

1. Turn off MySQL service

[Email protected] ~]# mysqladmin-uroot-poldboy123-s/data/3306/mysql.sock shutdown  ==> via mysqladmin Shutdown gracefully shuts down the MySQL service. [Email protected] ~]# lsof-i:3306

2, use the--skip-grant-tables parameter background to start MySQL, ignore authorization authentication Direct login

[Email protected] ~]# mysqld_safe--defaults-file=/data/3306/my.cnf--skip-grant-tables &  ==>-- Skip-grant-tables This parameter must be placed behind the default file,& indicates a background boot. [1] 63540[[email protected] ~]# 160216 22:27:26 mysqld_safe Logging to '/data/3306/mysql_oldboy3306.err '. 160216 22:27:26 Mysqld_safe starting mysqld daemon with databases From/data/3306/data^c[[email protected] ~]# lsof-i:3306command   PI D  USER   FD   TYPE DEVICE size/off NODE namemysqld  64277 mysql   12u  IPv4 127392      0t0  TCP * : MySQL (LISTEN)

3. Log in to MySQL and use the UPDATE statement to modify the MySQL root password

[[email protected] ~]# mysql-s/data/3306/mysql.sock   ==> did ignore authorization authentication, without password directly login; Welcome to the MySQL monitor.  Commands End With; or \g.your MySQL connection ID is 1Server version:5.5.32-log Source distributioncopyright (c), +, Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> update mysql.user set Password=password ("oldboy123") where user= ' Root ' and host= ' localhost '; ==> use the UPDATE statement to modify the MySQL root password. Query OK, 0 rows affected (0.26 sec) rows matched:1  changed:0  warnings:0mysql> flush privileges;  ==> Be sure to refresh the authorization table. Query OK, 0 rows affected (0.05 sec) mysql> \qbye

4. Log in to MySQL using the modified root password

[[email protected] ~]# mysql-uroot-poldboy123-s/data/3306/mysql.sock  ==> Log in with the root password. Welcome to the MySQL Monitor.  

At this point, retrieve and modify the root password successfully.

MySQL Root Password recovery

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.