How to change MySQL root password

We can change the password using SET PASSWORD() function or by using UPDATE command.

Change MySQL root password up to 5.6 versions:

USE mysql
UPDATE user SET PASSWORD = PASSWORD(‘mysql@123’)
WHERE Host = ‘localhost’ AND User = ‘root’; flush privileges;

or

SET PASSWORD FOR root@’localhost’ = PASSWORD(‘mysql@123’); flush privileges;

For both above methods, if miss to run flush privileges;, changes will not effect.

Change MySQL root password from 5.7 or later versions:

In MySQL 5.7, the password field in mysql.user table field was removed, now the field name is authentication_string.

mysql> update user set authentication_string=password(‘mysql@123′) where user=’root’;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

How to change MySQL root password

or

SET PASSWORD FOR root@’localhost’ = PASSWORD(‘mysql@123’); flush privileges;

Related Posts

CheapSexCams
Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools