MySQL forgot root password solution

Source: Internet
Author: User

# 1. Stop the MySQL process [[email protected] ~]#/etc/init.d/mysqld stopshutting down MySQL ... success! [[email protected] ~]## 2.mysqld_safe configuration Skip Authorization table start mysql[[email protected] ~]# mysqld_safe--skip-grant-tables --user=mysql &[1] 1670[[email protected] ~]# 170311 15:00:16 mysqld_safe Logging to '/application/mysql-5.1.72 /data/standby.err '. 170311 15:00:16 Mysqld_safe starting mysqld daemon with databases from/application/mysql-5.1.72/  Data[[email protected] ~]## 3. Enter mysql[[email protected] ~]# mysqlwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.1.72 Source distributioncopyright (c), +, Oracle and/or its a Ffiliates. 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># 4. Change the root password mysql> use mysql;database changedmysql&Gt mysql> Update user Set Password=password (' 123456 ') where user= ' root ' and host= ' localhost '; Query OK, 1 row affected (0.01 sec) Rows matched:1 changed:1 warnings:0mysql> mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec) mysql> Select User,host,password from mysql.user;+------+-----------+------------ -------------------------------+| user | Host | Password |+------+-----------+-------------------------------------------+| Root | localhost | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | Wiki | localhost | *a5db2d927d6df94da5e1ce4b293aeaab4d8304ea | | Root |                                           127.0.0.1 | |+------+-----------+-------------------------------------------+3 rows in Set (0.00 sec) mysql> Delete from user where user= ' root ' and host= ' 127.0.0.1 '; Query OK, 1 row Affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec) mysql> Select User,host,password from mysql.user;+------+-----------+-------------------------------------------+| user | Host | Password |+------+-----------+-------------------------------------------+| Root | localhost | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | Wiki | localhost | *a5db2d927d6df94da5e1ce4b293aeaab4d8304ea |+------+-----------+-------------------------------------------+2 Rows in Set (0.00 sec) mysql># 5. Stop the MySQL process on mysqld_safe mode [[email protected] ~]# mysqladmin-uroot-p123456                    shutdown170311 15:11:08 mysqld_safe mysqld from PID file/application/mysql-5.1.72/data/standby.pid ended[1]+ done Mysqld_safe--skip-grant-tables--user=mysql[[email protected] ~]# [[email protected] ~]# [[EMAIL&N Bsp;protected] ~]# lsof-i:3306[[email protected] ~]# ps-ef |grep mysqlroot 1967 1330 0 15:11 PTS/1 00:0 0:00 grep--color=auto mysql# 6. Normal open mysql[[email protected] ~]#/etc/init.d/mysqld startstarting MySQL. success! [[email protected] ~]#

  

MySQL forgot root password solution

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.