• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Reset MariaDB root Password in Linux

Written by Rahul, Updated on November 15, 2018
MariaDB mariadb, mysql, password, root

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.

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)]> 

Share it!
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Related Posts

  • How To Install LAMP (Apache, MySQL, PHP) on Debian 10

    November 24, 2019
  • How to Install MariaDB 10.4 on CentOS 8 & RHEL 8

    October 20, 2019
  • How To Install MariaDB on Debian 10 (Buster)

    October 16, 2019
  • How To Install MySQL on Debian 10 (Buster) Linux

    July 23, 2019
  • How To Install MySQL 8.0 on CentOS/RHEL 7/6 & Fedora 30/29

    June 23, 2019

5 Comments

  1. Avatar Jorge Reyes-Spindola Reply to Jorge
    May 22, 2018 at 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.

  2. Avatar Edwin Solares Reply to Edwin
    September 18, 2017 at 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.

  3. Avatar Roland Reply to Roland
    January 12, 2017 at 10:38 am

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

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

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

  5. Avatar Fernando Perez Reply to Fernando
    November 4, 2016 at 1:44 pm

    Great. It works. Thanks.

Leave a Reply

Cancel reply

Popular Posts

  • How to Install Python 3.8 on Ubuntu, Debian and LinuxMint
  • How to Restart Network Service on CentOS 8 or RHEL 8
  • How to Check IP Address on CentOS 8
  • How to Install Java 11/8 on Amazon Linux
  • How to Configure Static IP on CentOS 8 (CLI)
Copyright © 2013-2019 TecAdmin.net. All Rights Reserved. This site uses cookies. By using this website you agree with our term and services
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkNo
Revoke cookies