Step by step guide to reset root password in Mysql

Working with MySQL or MariaDB database, you might have faced a situation where you might have forgotten root or another user’s password or being SysAdmin, you might have had to deal with users who have forgotten their password. In this tutorial, we will learn reset root password in Mysql or resetting any other user account’s password (same steps can also be used to reset user’s password in MariaDB as well).

here, we have used “ User=’root’ ” to change the root user account password but we can also reset the password for another account by replacing ‘root’ with that user account. Now run the following command to exit out of mysql safely,

$ FLUSH PRIVILEGES;

$ exit;

Restart MySQL server to & then we will be able to login to root account with the updated password. For Centos/RHEL, run