[Mysql] Common commands-forgot password
The previous article basically summarized how to create a user using commands in myql. For details, see [Mysql] Common commands-user operations (create, authorize, modify, and delete)
What should I do if I forget my password in special circumstances today ???
You can reinstall or delete configurations to complete this operation. What should I do if I don't reinstall it?
Principle:
Run -- skip-grant-tables to skip grant-tables to start the database.
Let's take a look at the following:
In linux:
1. Shut down the mysql process, such as service mysql stop or ps-ef | grep mysql kill (mysqlpid) and rcmysqld stop.
2. Add the startup parameter: You can edit/etc/my. ini or/etc/my. run the/usr/bin/mysqld_safe -- skip-grant-tables command to start mysql.
3. Enter the system without a password and change the password: mysql-u root-p.
The same is true for windows, but the operations are different.
1. Right-click my computer, choose "manage" service ", find mysql, stop mysql, run cmd with win + R, and run net stop mysql.
2. Use the -- skip-grant-tables parameter to start the database.
C: \ Users \ WJ> net stop mysqlMySQL service is stopping .. MySQL service has stopped successfully. C: \ Users \ WJ> mysqld -- skip-grant-tables
3. Use root to log on.
4. Stop or use this parameter again.