To reset the root password in MySQL, you can follow the steps below:
- Stop the MySQL service:
sudo service mysql stop
- Start MySQL in safe mode:
sudo mysqld_safe --skip-grant-tables --skip-networking &
- Connect to the MySQL server:
mysql -u root
- At the MySQL prompt, enter the following commands:
use mysql;
update user set authentication_string=PASSWORD("new_password") where User='root';
flush privileges;
quit;
Note: Replace “new_password” with the desired new password.
- Stop the MySQL service:
sudo service mysql stop
- Start MySQL normally:
sudo service mysql start
You should now be able to log in to MySQL with the new root password.