How to change Mysql root password


Step 1:

mysql -u root -p

Result:

[root@tutorialspots ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.16

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Step 2:
As of MySQL 5.7.6, use ALTER USER:

mysql> ALTER USER user IDENTIFIED BY 'new_password';

Before 5.7.6, use SET PASSWORD:

mysql> SET PASSWORD FOR user = PASSWORD('new_password');

Note: you must use strong password like: Tutorialspots*123456

Example:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Tutorialspots*123456';

change root mysql password

Result:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Tutorialspots*123456';
Query OK, 0 rows affected (0.00 sec)

Similar tutorial:
Change root password MYSQL in Kloxo via SSH

1 Comment

Leave a Reply