Blog MySQL

update user password in mysql

Apparently, quite a number of people are looking into my humble website trying to find out how to change a password of an existing user. Doing this is easy in Oracle with a ALTER USER command. In MySQL, it is different in such a way that you need to update a table. Here's the command.

UPDATE mysql.user
SET password = PASSWORD('mynewpassword')
WHERE user = 'kwatog';


An alternative (and apparently official one) is by using the syntax below.

PASSWORD('some password')
| OLD_PASSWORD('some password')
| 'encrypted password'

Example :

SET PASSWORD 'kwatog'@'localhost = PASSWORD('mynewpassword')

Still can't believe? Go head to the official documentation of MySQL at the following URL.