Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Databases»MariaDB»How to Reset MariaDB root Password in Linux

    How to Reset MariaDB root Password in Linux

    By RahulNovember 15, 20182 Mins Read

    Have you forgotten MariaDB root password? You don’t know how to recover it. Not to worry, this tutorial will help you to reset MariaDB root password on Linux system.

    Advertisement

    Reset MariaDB root Password

    Let’s follow this step by step tutorial to reset MariaDB root password on your Linux systems.

    Step 1 – Start MariaDB in Safe Mode

    First of all, you need to stop MariaDB service on your system. You can do this using the following command.

    sudo systemctl stop mysql.service
    

    Now start your MariaDB service in safe mode using skip grant and run this command in the background.

    mysqld_safe --skip-grant-tables &
    

    Step 2 – Change Password

    After starting MariaDB in safe more connect to MariaDB with root user and without any password. After that run following command to change the root user password.

    mysql -u root
    

    1
    2
    3
    > use mysql;
    > UPDATE user SET authentication_string = password("SecreT") where User='root';
    > FLUSH PRIVILEGES;

    Step 3 – Stop and Start MariaDB

    After successfully changing the password, stop the MariaDB service and start it again in normal mode using following commands.

    sudo systemctl stop mysql.service
    sudo systemctl start mysql.service
    

    Step 4 – Login with New Password

    You have now new root user password for your MariaDB instance. Login to MariaDB instance to verify the new password.

    mysql -u root -p
    
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 3
    Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1
    
    Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> 
    

    mariadb MySQL password root
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    (Resolved) MySQL connection error: certificate verify failed

    How to Connect Python with MySQL Database

    How to Generate Random Passwords in Python

    How to Generate Random Password in Python

    View 5 Comments

    5 Comments

    1. Jorge Reyes-Spindola on May 22, 2018 11:47 pm

      I was recently installing mysql in Ubuntu Bionic Beaver and the command ‘UPDATE User SET password…’ does not apply here. Instead, you have to do

      UPDATE User SET authentication_string = password(“Mypassword”) where User=’root’;

      for the password to be updated.

      Thanks for the great post.

      Reply
    2. Edwin Solares on September 18, 2017 4:39 pm

      One issue. is you have to be logged in as a system root user for all these commands, if not, then use sudo and then the command. i.e. sudo mysqld_safe –skip-grant-tables &

      If you are not logged in as a root user, then you will get many issues and not be able to reset your password. Also I would avoid using # or @ in your passwords.

      Reply
    3. Roland on January 12, 2017 10:38 am

      Thank you very much for this short, yet very helpful article!

      Reply
    4. Jorge F. Reyes-Spindola on November 28, 2016 11:02 pm

      Excellent explanation, just saved my butt. Thank you very much.

      Reply
    5. Fernando Perez on November 4, 2016 1:44 pm

      Great. It works. Thanks.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.