Category Archives: MySQL

Reset the password for the user in MySQL Server

Change the password for the user in MySQL Server

Connect with superuser root and check the user present:

mysql> select host,user from mysql.user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | mysqlbackup      |
| localhost | mysqlbackup1     |
| localhost | root             |
| localhost | test             |
+-----------+------------------+
7 rows in set (0.03 sec)

Change or Reset the password with the following two commands:

mysql> ALTER USER 'test'@'localhost' identified by 'Mypassword';
Query OK, 0 rows affected (0.03 sec)

OR

mysql> set password for 'test'@'localhost'='MyPassword';
Query OK, 0 rows affected (0.08 sec)