MySQL : How do I change a user's password?
What's in the box?
How do I change a user's password on MySQL or MariaDB? That's the question we're going to answer in this tutorial. This relatively simple procedure can be useful if you forget the password to an account, or if you wish to renew the password for security reasons.
To do this, you need to know the MySQL instance's root password. Resetting the MySQL root password is not covered in this article. Here, we're going to change the password of the user named " user_tutobox" .
Need help installing MySQL on Debian? Follow this tutorial :
1. Connect to MySQL instance
The first thing to do is to connect to the MySQL instance from the command line (or via another application such as PhpMyAdmin).
mysql -u root -p
Enter the root password and you should have access to the MySQL prompt. If you're using MySQL on Windows, you'll need to call the " mysql.exe" . This procedure therefore applies to Windows and Linux.
2. Changing a MySQL user's password
From now on, we'll use the " ALTER USER "to change the user's password". user_tutobox "On local connections. In the following example, the password " P@ssword! "is assigned to the user.
ALTER USER 'user_tutobox'@'localhost' IDENTIFIED BY 'P@ssword!
Finally, it is necessary to reload privileges to apply the modification immediately:
FLUSH PRIVILEGES;
You can exit the prompt :
exit;
Image manipulation :
To validate the new password, you can try logging in with the user and password :
mysql -u user_tutobox -p
Here, enter your new password: if the connection works, you're all set!
3. Conclusion
Thanks to this article in the IT tutorials box, you've learned how to change a MySQL user's password. A simple action, but one that can be very useful in some cases... Don't you think?