Asked 7 years ago
28 Feb 2017
Views 1015
pratik

pratik posted

how to reset MySQL admin password ?

i installed wamp and now i try to login at phpMyAdmin but i forgot password of admin of MySQL which i define at the time of installation and now i tried many combination of username and password and its not working . i think i am lost now.

so what to do recover or reset the admin password of MySQL ?
dilip

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.
Post Answer