DEV Community

Alaa Mekibes
Alaa Mekibes

Posted on

How to Reset a Forgotten MariaDB User Password

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.

How to reset user password in MariaDB?

Change MariaDB password using command line

  • Open a terminal.
  • Stop the currently running MariaDB database.
sudo systemctl stop mariadb
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode
  • Now, open a new terminal.
  • Login to MariaDB as root. Don't worry, it won't ask you about the password.
mariadb -u root
Enter fullscreen mode Exit fullscreen mode
  • Run the FLUSH PRIVILEGES command and then change the root password with the command below. Change this NEW_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
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode
  • Congratulations! You’ve successfully changed the password. Now, go ahead and test it out!
mariadb -u root -p
Enter fullscreen mode Exit fullscreen mode

Thanks for reading!

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay