How To Change MySQL Password of Existing User?
MySQL Change a User Password
Suppose your MySQL user is "my-mysql-user" and you want to set a new password "mynewpassword", then follow the procedure below to change the password:
Login to MySQL shell by running the following command and enter password for root user when prompted:
mysql -uroot -p
After logging into MySQL shell, run the following command:
Suppose your MySQL user is "my-mysql-user" and you want to set a new password "mynewpassword", then follow the procedure below to change the password:
Login to MySQL shell by running the following command and enter password for root user when prompted:
mysql -uroot -p
After logging into MySQL shell, run the following command:
mysql> use mysql; mysql> SET PASSWORD FOR 'my-mysql-user'@'localhost' = PASSWORD('mynewpassword'); Query OK, 0 rows affected (0.00 sec)
Alternatively you can also use the below command:
mysql>UPDATE mysql.user SET Password=PASSWORD('mynewpassword') WHERE User='my-mysql-user' AND Host='localhost';
Finally run the following command:
mysql>FLUSH PRIVILEGES;
Now the password for "my-mysql-user" has been changed to "mynewpassword". You may login to MySQL shell by the following command:
mysql -umy-mysql-user -pmynewpassword
0 comments:
Post a Comment