How To Change User Password In MySQL Server 5.x On CentOS

How To Change User Password In MySQL Server 5.x On CentOS

If you’re not aware of how to change user password in MySQL server, so you can run the below commands to change it very easily but commands vary from version to version.

Check Out : Solve MySQL Too Many Connections Error

Login the database server using mysql -u root -p

Now switch to MySQL database, 

use mysql;

ALTER USER ‘userName’@’localhost’ IDENTIFIED BY ‘New-Password-Here’;

If these commands does not work for you, So you may run the below commands.

1. SET PASSWORD FOR ‘user’@’localhost’ = PASSWORD(‘MyNewPass’);

Or you can also use this command to update the password of a user. 

2. UPDATE mysql.user SET Password=PASSWORD(‘newpass’) WHERE User=’user’ AND Host=’host’;

Check Out :  Enable MySQL General Query Log

There’re another ways to change the user password. let’s explore them. With a for user clause, run the below command but user must exist,

SET PASSWORD FOR ‘user’@’localhost’ = ‘auth_string’

Without a for user clause, run the below command for current user,

SET PASSWORD = ‘auth_string’;

you can change password of any client which connects the server using user and password. 

Check Out : Could Not Find Driver With Class Name: com.mysql.jdbc

To see which account the server authenticated you,

select current_user();

Then run the command to set the password,

SET PASSWORD FOR ‘user’@’%.exam.org’ = ‘auth_string’;

You’re done

About Helios Smith

Author is a avid reader

Latest Posts
Follow Us
Get the latest news delivered daily!