How to Reset MySQL or MariaDB Root Password in Linux

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Gabriel Cánepa

Gabriel Cánepa is a GNU/Linux sysadmin and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

7 Responses

  1. saravanakumar says:

    Hi do you have any doc for how to reset root password for MySql8.0

  2. arun says:

    Not useful. Practical approach is appreciated

  3. arun says:

    This method is not working with MySQL 8.0 version on CentOS 7 Server. Can you help on this?

    • Ravi Saive says:


      Please follow this link to reset MySQL 8 root password:

      • arun says:

        Thanks for immediate revert @ Ravi. I followed that URL but no luck. Can you help step by step with snapshots?

        • Ravi Saive says:


          I need a time to test it, take screenshots and document it. Give me a day or two to publish the article on same..

        • Ravi Saive says:


          To reset root password in MySQL 8 version, use the followinig instructions.

          1. First, stop the MySQL server and then restart it with the –skip-grant-tables option as shown.

          # systemctl stop mariadb
          # systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
          # systemctl start mariadb

          2. In the mysql client shell, tell the server to reload the grant tables so that account-management statements work.

          mysql> FLUSH PRIVILEGES;

          3. Then change the ‘root’@’localhost’ account password. Make sure to replace the password with the password that you want to use.

          mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

          4. Now stop the server, unset (the –skip-grant-tables) and restart the service.

          # systemctl stop mariadb
          # systemctl unset-environment MYSQLD_OPTS
          # systemctl start mariadb

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.