MySQL Reset Root Password

To reset the root password in MySQL, you can follow the steps below:

  1. Stop the MySQL service:
    sudo service mysql stop
  2. Start MySQL in safe mode:
    sudo mysqld_safe --skip-grant-tables --skip-networking &
  3. Connect to the MySQL server:
    mysql -u root
  4. 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.

  5. Stop the MySQL service:
    sudo service mysql stop
  6. Start MySQL normally:
    sudo service mysql start

You should now be able to log in to MySQL with the new root password.

Leave a Comment