change mysql user password

How To Change User Password In MySQL Server 5.x 

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. MySQL can alter the user password using the command line.

Check Out: Solve MySQL Too Many Connections Error

Log in 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 do 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 other 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 user clause, run the below command for the current user,

SET PASSWORD = 'auth_string'; 

you can change the 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 mysql alter user

Leave a Reply

avatar
  Subscribe  
Notify of