mysql:recover_the_mysql_root_password
MySQL - Recover the MySQL root password
To recover the MySQL root Password, please follow these steps:
1. Stop the MySQL server process.
/etc/init.d/mysql stop
2. Start the MySQL process with the –skip-grant-tables option, so that it will not prompt for a password.
mysqld_safe --skip-grant-tables &
displays:
root@sharewiz:/root# mysqld_safe –skip-grant-tables & [1] 4376 root@sharewiz:/root# 170712 03:12:56 mysqld_safe Logging to syslog. 170712 03:12:56 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
3. Connect to a MySQL as the root user.
mysql -u root
displays:
Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 9 Server version: 5.7.12 (Debian) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement. mysql>
4. Set the new password for the MySQL root account.
mysql> use mysql; mysql> update user set password=PASSWORD("NEW-PASSWORD") where user='root'; mysql> flush privileges; mysql> quit
5. Exit and then stop and start or restart the MySQL server.
/etc/init.d/mysql restart
mysql/recover_the_mysql_root_password.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1