Recovering Lost MySQL root
You can recover a MySQL database server password with the following steps:
2. Start the MySQL server w/o password :
3. Connect to the MySQL server using the MySQL client:
4. Which will bring you to below :
5. Set a new MySQL root user password:
6. Stop the MySQL services .
7. Start again and try to access using the new one.
Thank you.
- Stop the MySQL Processes :
[[email protected] ~]# service mysqld stop
Stopping mysqld: [ OK ]
[[email protected] ~]#
2. Start the MySQL server w/o password :
mysqld_safe --skip-grant-tables &
3. Connect to the MySQL server using the MySQL client:
mysql -u root
4. Which will bring you to below :
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.53 MySQL Community Server (GPL) by Remi
Copyright (c) 2000, 2016, 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>
5. Set a new MySQL root user password:
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
6. Stop the MySQL services .
7. Start again and try to access using the new one.
Thank you.