dilip
answered Apr 24 '23 00:00
To reset the admin password for your MySQL database, you can follow the steps below:
1.Stop the MySQL service by running the following command:
sudo systemctl stop mysql
2.Start the MySQL service without loading the grant tables by running the following command:
sudo mysqld_safe --skip-grant-tables &
3.Log in to MySQL as the root user by running the following command:
mysql -u root
4.Once you're logged in, set a new password for the root user by running one of the following commands (depending on your MySQL version):
For MySQL versions before 5.7.6:
UPDATE mysql.user SET authentication_string=PASSWORD('new_password') WHERE User='root';
For MySQL versions 5.7.6 and later:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Be sure to replace "new_password" with your desired password.
5.To ensure that the changes take effect, run the following command to flush the privileges:
FLUSH PRIVILEGES;
6.Exit from the MySQL prompt by running the following command:
exit;
7.Finally, restart the MySQL service by running the following command:
sudo systemctl start mysql
Once you have completed these steps, you should be able to log in to MySQL using the new password for the root user. If you encounter any issues or errors during this process, it is recommended that you consult the official MySQL documentation or seek assistance from a MySQL expert.