Home >Database >Mysql Tutorial >Summary of MYSQL using cmd command to change root password

Summary of MYSQL using cmd command to change root password

伊谢尔伦
伊谢尔伦Original
2017-04-29 10:41:332586browse

1. How to change the root administrator password of mysql in the win2K command prompt?

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

You can change the password directly through this method. As for whether you can log in to MySQL under CMD, you need to add "C:\Program Files\MySQL\MySQL Server 5.0\bin;" to the Windows environment variable PATH (please change it to your own installation path).

2. MYSQL modify root password command

Switch to the mysql installation directory under cmd
Example
d:/mysql/bin
Prerequisite: the mysql user root password is empty .
Enter mysql -u root mysql
mysql> state 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> 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 will start executing the command line
And the second command Will update the mysql system database that has been loaded into memory

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

The above is the detailed content of Summary of MYSQL using cmd command to change root password. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn