Have you or one of your MySQL users forgotten the password to a MySQL account? It's very easy to reset a MySQL user password on Linux, and we'll show you the commands and step by step instructions below.
Changing the MySQL root password is a bit more involved, so we've written a separate guide on how to change MySQL root password.In this tutorial you will learn:
- How to change MySQL user password
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux disto|
|Other||Privileged access to your Linux system as root or via the
# - requires given linux commands to be executed with root privileges either directly as a root user or by use of
Change MySQL User Password
Open a terminal on your machine and follow the steps below.
- Start by logging into MySQL as the root user and switch to the
$ mysql -u root -p mysql> use mysql;
- Switch the user's password by using the following syntax (replace values where necessary).
mysql> ALTER USER 'user'@'localhost' IDENTIFIED BY 'new_password';
- Lastly, flush privileges and exit MySQL.
mysql> FLUSH PRIVILEGES; mysql> exit
That's all there is to it. Make sure the changes worked by trying to login from your shell with the new password.
$ mysql -u username -p
As you can see, changing a user password in MySQL is quite simple. Hopefully you have found this short guide to be helpful.