Problems activating your account? Send notification email to: admin@post4vps.com
Host4Fun Budget VPS Hosting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reset MariaDB Root Password
#1
Hello!

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:
    FLUSH PRIVILEGES;
  8. Use the command below to set a new password for the root user:
    UPDATE USER SET PASSWORD=PASSWORD("newpasswordhere") WHERE USER='root';

    Make sure to replace "newpasswordhere" with the new password for the MySQL root user.
  9. Flush privileges again to reload permissions of the users:
    FLUSH PRIVILEGES;
  10. Logout and close the MySQL command line:
    exit
  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.
Thanks a lot for the free VPS 16 Post4VPS & HostLease!
Reply
#2
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
Gimme +rep Heart
[Image: img.php?userid=496]
Thanks For Post4VPS and HostLease for the amazing VPS 18
Reply
#3
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. 
Reply
 


Possibly Related Threads...
Thread Author Replies Views Last Post
  How to create PuttyGen keys for accessing a VPS and disable password authentication deanhills 7 1,654 07-02-2018, 01:59 PM
Last Post: Rehan
  How to password protect some Web pages in Apache with .htaccess deanhills 5 2,391 04-30-2018, 10:24 AM
Last Post: deanhills
  How to change "RCON Password" at SA-MP Server youssefbasha 4 3,484 06-19-2017, 08:53 PM
Last Post: YOuNeS_Dz
  How to setup ROOT on mobile. youssefbasha 8 3,333 04-22-2017, 10:59 AM
Last Post: humanpuff69
  Install nginx, php, mariadb - Ubuntu 14.04 Neco 0 889 12-02-2016, 02:36 PM
Last Post: Neco

Forum Jump:


Users browsing this thread: 1 Guest(s)
Hostlease

Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - SSDBlaze - Abc-Hosters - Hyper Expert - Shadow Hosting - Bladenode - HostDoc - Hostlease


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.