Problems activating your account? Send notification email to: [email protected]
Host4Fun Budget VPS Hosting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reset MariaDB Root Password

A brief quide on how to reset the MariaDB MySQL root password if you forgot it or your previous password stopped working for some reason. You will need root or sudo access on your server to do the following steps.

  1. Connect to your server via SSH or any other similar means of remote access for Linux servers.
  2. Login as root or a user that has administrative permission through the "sudo" application.
  3. Stop all MariaDB MySQL processes using the command below (outfitted for more recent Linux distributions using systemd!):
    systemctl stop mariadb

    Don't forget to use sudo infront of the command if you're not root!
  4. Now start MariaDB MySQL in safemode using the following command:
    mysqld_safe --skip-grant-tables &

    Don't forget to use sudo infront of the command if you're not root! The safemode will allow to login as root without a password as a mean of emergency access to the database.

    After running this command it might seem like it's stuck. Simply press the ENTER key to continue in the command line.
  5. Start the MySQL command line tool and login as MySQL root:
    mysql -u root
  6. Select the "mysql" database as that is where the user accounts and other server information is stored:
    USE mysql;
  7. Flush privileges to avoid error messages about "insecure execution" of queries:
  8. Use the command below to set a new password for the root user:

    Make sure to replace "newpasswordhere" with the new password for the MySQL root user.
  9. Flush privileges again to reload permissions of the users:
  10. Logout and close the MySQL command line:
  11. Stop the MariaDB safemode:
    killall mysqld
  12. Start all normal MariaDB processes:
    systemctl start mariadb

That's it folks. This is how you reset passwords for MySQL root or actually also any other MySQL user from the command line.

BE CAREFUL WITH THE USE OF MYSQL IN SAFEMODE! It's basically like an open bank vault.
Awesome tutorial, i used Google before u post this xD
Thanks for this tutorial @Hidden and also thanks for helping me in my MySQL problem
I'd consider this an idea for my next blog post. Thank you!

I think you should change the title to "How to reset MariaDB root password" because I think that is what it suits.
Premium Web Hosting | ShadowCrypt | Manal Shaikh Official Website
If you find my post/thread useful, you're supposed to +rep me. 

Possibly Related Threads...
Thread Author Replies Views Last Post
  Host Your Own WP Blog (Debian 10, Nginx, PHP 8 & MariaDB) Mashiro 14 387 05-28-2021, 05:25 AM
Last Post: fChk
  Password Recovery Ubuntu Server 18.04 LTS Mashiro 4 1,825 07-24-2020, 10:41 PM
Last Post: deanhills
  How to create PuttyGen keys for accessing a VPS and disable password authentication deanhills 7 3,120 07-02-2018, 01:59 PM
Last Post: Rehan
  How to password protect some Web pages in Apache with .htaccess deanhills 5 3,509 04-30-2018, 10:24 AM
Last Post: deanhills
  How to change "RCON Password" at SA-MP Server youssefbasha 4 5,230 06-19-2017, 08:53 PM
Last Post: YOuNeS_Dz

Forum Jump:

Users browsing this thread: 1 Guest(s)

Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting

About Post4VPS

Post4VPS is a forum/destiny where you can Delploy Your Free VPSs just by the Power of Posts.

We Provide VPSs of many locations like Germany,US,Canada,France,London,etc.

We also Provide VPSs of Both Linux and Windows OS.