Can you explain how to change the password for user account in MySQL?
- Password in MySQL can be changed using SET PASSWORD command.
- The SET PASSWORD statement assigns a password to a MySQL user account:
1. With no FOR user clause, this statement sets the password for the current user:
SET PASSWORD = password_option;
- Any client who connects to the server using a non anonymous account can change the password for that account. To see which account the server authenticated you as, invoke the CURRENT_USER() function:
SELECT CURRENT_USER();
2. With a FOR user clause, this statement sets the password for the named account, which must exist:
SET PASSWORD FOR 'reema'@'localhost' = password_option;
- In this case, you must have the UPDATE privilege for the mysql database.
- To change in a non encrypted format:
SET PASSWORD = PASSWORD('passwordString');
- To change in an encrypted format:
SET PASSWORD = 'encryptedPasswordString';