If you have lost the password for the MySQL root
user, you can reset it by following these steps:
sudo systemctl stop mysql
--skip-grant-tables
option. This will allow you to bypass the password authentication for the root
user:sudo mysqld_safe --skip-grant-tables &
root
user using the mysql
command-line client:mysql -u root
You will not be prompted for a password.
root
user:SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
Replace new_password
with the password you want to use.
mysql
command-line client and stop the MySQL server:exit sudo systemctl stop mysql
sudo systemctl start mysql
You should now be able to log in to the MySQL server as the root
user using the new password.
Keep in mind that these steps are specific to a Linux or Unix system. If you are using a different operating system, the steps to reset the root
password may be different.