over 4 years ago

There will be times when the root password for your MySQL instance is either forgotten or compromised. This calls for you to reset the root password.

The follwing steps will walk you through how to reset the root password for MySQL.

  1. Stop the MySQL process.

    # service mysqld stop

    Once MySQL has stopped

  2. Restart it with the --skip-grant-tables option.

    # mysqld_safe --skip-grant-tables &
  3. Connect to MySQL using the root user.

    # mysql -u root

    Once logged in, you should see the following prompt:


    Tell MySQL which database to use:

    mysql> use mysql;

    Enter the new password for the root user as follows:

    mysql> UPDATE user SET password=PASSWORD("YOUR NEW PASSWORD HERE") WHERE User='root';

    Flush the privileges:

    mysql> flush privileges;

    Exit MySQL:

    mysql> quit
  4. Now stop MySQL again.

    # service mysqld stop
  5. Now restart MySQL.

    # service mysqld restart

    Test your new login.

    # mysql -u root -p


← Zabbix Installation Hello World →
comments powered by Disqus