MySQL - How to change the password for user account in MySQL

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';
MySQL - What are user privileges in MySQL?
What are user privileges in MySQL? - Privileges in MySQL are used to restrict users accessing data objects and functions. Below are the commonly used......
MySQL - What are the scope levels a user privilege can be granted?
What are the scope levels a user privilege can be granted? - Global Level – This privilege applies to ALL databases present. Privileges granted at the global level stored in mysql.user table......
MySQL - Explain how to view and Revoke user privileges in MySQL
Explain how to view and Revoke user privileges in MySQL - Privileges assigned to users can be viewed using the SHOW GRANTS USER_NAME command......
Post your comment