arrow_upward

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.
[Image: zHHqO5Q.png]


Messages In This Thread
Reset MariaDB Root Password - by Mashiro - 07-27-2019, 09:03 AM
RE: Reset MariaDB Root Password - by youssefbasha - 07-27-2019, 09:04 AM
RE: Reset MariaDB Root Password - by Manal - 07-27-2019, 04:42 PM


person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting