Change USER password in MySQL

We can the user password in MySQL, using UPDATE, SET, ALTER command. To change password, current login user must have granted permissions on user table of mysql database and must have UPDATE, SET and ALTER permissions on user table.

To reset password in MySQL 5.6 or older versions(This statement not works in MySQL 5.7 or later versions. Password filed is replaced with authentication_string field in MySQL 5.7 Version)

UPDATE mysql.user SET Password=PASSWORD(‘NewPassHere’) WHERE User=’admin’;

To reset password in MySQL 5.7 or later versions

UPDATE mysql.user SET authentication_string=PASSWORD(‘NewPassHere’) WHERE User=’admin’;


SET PASSWORD FOR ‘admin’@’localhost’ = PASSWORD(‘MyNewPass’);

Using ALTER command:

ALTER USER ‘admin’@’localhost’ IDENTIFIED BY ‘mysql@123’;

Related Posts

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools
%d bloggers like this: