MySQL Change a User Password Command Tutorial

MySQL Change a User Password Command Tutorial

To change the password for a MySQL user account, you will need to have access to the current password for the user account or have the appropriate privileges to change the password.

To change the password for a MySQL user account, follow these steps:

  1. Connect to the MySQL server using the mysql utility. You can use the mysql utility to connect to the MySQL server as the root user or another user with the appropriate privileges. For example:
refer to:‮ual‬tturi.com
mysql -u root -p

Enter the password for the user account when prompted.

  1. Use the SET PASSWORD command to change the password for the user account. You can use the following command to change the password for a user account:
mysql> SET PASSWORD FOR 'username'@'localhost' = PASSWORD('newpassword');

Replace username with the name of the user account, and newpassword with the new password you want to set for the user account.

  1. Flush the privileges. After changing the password for the user account, you will need to flush the privileges to make the changes take effect. You can do this using the FLUSH PRIVILEGES command:
mysql> FLUSH PRIVILEGES;
  1. Disconnect from the MySQL server. Once you have finished changing the password and flushing the privileges, you can disconnect from the MySQL server by typing exit at the MySQL prompt:
mysql> exit

After changing the password for the user account, you should be able to log in to the MySQL server using the new password for the user account.

Created Time:2017-10-30 10:17:51  Author:lautturi