This article will share with you a detailed explanation of the command for modifying the root password in mysql. If you need to know how to change the root password, refer to it.
MYSQL command to change the root password
Switch to the mysql installation directory under cmd
Example
D:/mysql/bin
Prerequisites: the mysql root Password is empty.
Enter mysql-u root mysql
Mysql> enter update user set password = password ('new password') where user = 'root ';
Echo
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
Mysql> Status, enter flush privileges;
Echo
Query OK, 0 rows affected (0.00 sec)
Mysql> enter quit
Exit SQL
Note that a semicolon ";" must be added after each command.
Mysql started to execute this command
The second command updates the database of the mysql system that has been loaded into the memory.
Restart mysql.
After the root password is updated, the method for connecting to MySQL is as follows:
New mysql-uroot-p Password
MYSQL command to change the root password
Switch to the mysql installation directory under cmd
Example
D:/mysql/bin
Prerequisites: the mysql root Password is empty.
Enter mysql-u root mysql
Mysql> enter update user set password = password ('new password') where user = 'root ';
Echo
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
Mysql> Status, enter flush privileges;
Echo
Query OK, 0 rows affected (0.00 sec)
Mysql> enter quit
Exit SQL
Note that a semicolon ";" must be added after each command.
Mysql started to execute this command
The second command updates the database of the mysql system that has been loaded into the memory.
Restart mysql.
After the root password is updated, the method for connecting to MySQL is as follows:
New mysql-uroot-p Password
TIPS: If you think it is too complicated to change the root password in command mode, you can use phpmyadmin to change the root password. This is very simple, however, after changing the password, phpmyadmin needs to reconfigure the user's logon password.