Did you or someone using MariaDB forget the password to an account? Don’t worry! Resetting a MariaDB user password on Linux is super easy. Here’s a quick guide with the commands and step-by-step instructions to help you out.
Change MariaDB password using command line
- Open a terminal.
- Stop the currently running MariaDB database.
sudo systemctl stop mariadb
- Restart the database process, but this time use the
--skip-grant-tables
option. This lets you connect to the database without needing a password.
sudo mysqld_safe --skip-grant-tables --skip-networking
- Now, open a new terminal.
- Login to MariaDB as root. Don't worry, it won't ask you about the password.
mariadb -u root
- Run the
FLUSH PRIVILEGES
command and then change the root password with the command below. Change thisNEW_PASSWORD_HERE
to your new password. Past these commands line by line inside MariaDB Monitor.
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEW_PASSWORD_HERE';
exit
- Close your first terminal.
- Stop the current mysqld process properly, and then restart your MariaDB server. Line by line.
sudo pkill mysqld
sudo systemctl start mariadb
- Congratulations! You’ve successfully changed the password. Now, go ahead and test it out!
mariadb -u root -p
Thanks for reading!
Top comments (0)