If you do not set a new password when installing mysql, the default value is null or 12456. In this case, you can use the command line mysql-uroot-p to log on. However, you do not want to leave the password blank during official use, or it is as simple as 123456. The following are four ways to force the mysql root Password to be modified: the first method is to use upd.
If you do not set a new password when installing mysql, the default value is null or 12456. In this case, you can use the command line mysql-uroot-p to log on. However, you do not want to leave the password blank during official use, or it is as simple as 123456. The following are four ways to force the mysql root Password to be modified: the first method is to use upd.
If you do not set a new password when installing mysql, the default value is null or 12456. In this case, you can use the command line mysql-uroot-p to log on. However, you do not want to leave the password blank during official use, or it is as simple as 123456. The following are four ways to force the mysql root Password Change:
Method 1: Use the update statement to modify
[Root @ localhost ~] # Mysql-uroot-p
Mysql-> user mysql;
Mysql> update user set Password = password ('newpassword') where User = 'root' and Host = 'localhost ';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> quit
Log on again.
Method 2: Use the mysql tool (mysqladmin)
[Root @ localhost ~] # Mysqladmin-u root-poldpassword password 'newpassword ';
Method 3: Use the set statement to modify
[Root @ localhost ~] # Mysql-uroot-p
Mysql-> user mysql;
Mysql> set password for root @ "localhost" = password ("newpassword ");
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> quit
Log on again.
Method 4: Use the grant statement to modify
[Root @ localhost ~] # Mysql-uroot-p
Mysql> user mysql;
Mysql> grant all privileges on *. * to root @ 'localhost' identified by 'newpassword ';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> quit
Log on again.
Method 5: Use phpmyadmin to modify the settings.
I personally tested the above methods. Each method can force the password of the root user of mysql to be modified.
Original article address: five ways to force the mysql root Password to be modified. Thank you for sharing it with the original author.