Lost MySQL Admin Password

Lost MySQL Admin Password

If you have lost the password for the MySQL root user, you can reset it by following these steps:

  1. Stop the MySQL server. On a Linux or Unix system, you can use the following command to stop the MySQL server:
‮‬refer to:lautturi.com
sudo systemctl stop mysql
  1. Start the MySQL server in safe mode with the --skip-grant-tables option. This will allow you to bypass the password authentication for the root user:
sudo mysqld_safe --skip-grant-tables &
  1. Connect to the MySQL server as the root user using the mysql command-line client:
mysql -u root

You will not be prompted for a password.

  1. Use the following MySQL command to reset the password for the root user:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');

Replace new_password with the password you want to use.

  1. Exit the mysql command-line client and stop the MySQL server:
exit
sudo systemctl stop mysql
  1. Start the MySQL server normally:
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.

Created Time:2017-10-30 10:17:49  Author:lautturi