MYSQL User Password Modification

To modify the password of an existing user we use the following syntax:


SET PASSWORD [FOR user] = PASSWORD('some password')

The SET PASSWORD statement assigns a password to an existing MySQL user account.

With no FOR clause, this statement sets the password for the current user. Any client that has connected to the server using a non-anonymous account can change the password for that account.

With a FOR clause, this statement sets the password for a specific account on the current server host. Only clients that have the UPDATE privilege for the mysql database can do this. The user value should be given in user_name@host_name format, where user_name and host_name are exactly as they are listed in the User and Host columns of the mysql.user table entry. For example, if you had an entry with User and Host column values of 'bob' and '%.loc.gov', you would write the statement like this:

SET PASSWORD FOR 'tom'@'localhost' = PASSWORD('newpass');

That is equivalent to the following statements:

UPDATE mysql.user SET Password=PASSWORD('newpass')

WHERE User='bob' AND Host='%.loc.gov';

FLUSH PRIVILEGES;

Note:

You can see which account the server authenticated you as by executing

SELECT CURRENT_USER()

2 Response to "MYSQL User Password Modification"

  1. This post gives a very simple syntax for modifying the existing user password in MySql. I tried the given syntax and modified my password. You can also use it for your reference. This is easiest way to do this.

    Unknown says:

    Thanks considering Your very good mail & comprise In Your web location. Plesant considered you share it intelligent keep it up
    FIN 370 Week 3

Post a Comment

Powered by Blogger