MYSQL modify root password command summary

  • 2020-05-12 06:19:58
  • OfStack

1. How do I change the root administrator password for mysql at the win2K command prompt?

> mysql -u root -p
Enter password: ******
mysql > use mysql;
mysql > update user set password=password('new_password') where user='root';

This way you can change the password directly. As for whether you can log in MySQL under CMD, add "C:\Program Files\MySQL\MySQL Server 5.0\bin;" to Windows environment variable PATH. Please change to your own installation path.

2. MYSQL modify root password command

Switch to the mysql installation directory under cmd
case
d:/mysql/bin
Premise: mysql user root password is empty.
Enter mysql-u root mysql
mysql > Enter update user set password=password(' new password ') where user='root';
The echo
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql > Enter FLUSH PRIVILEGES in the state;
The echo
Query OK, 0 rows affected (0.00 sec)
mysql > Enter quit in the state
Exit sql

Note that each command is followed by a semicolon ";"
mysql just started to execute this command
The second command updates the database of the mysql system that has been loaded into memory

Restart mysql.
Stop MYSQL
net stop mysql
Start MYSQL
net start mysql

Related articles: