Yesterday I forgot the password of the root user of the mysql database on a server. after searching and solving the problem, I learned that I could reset the root password as follows: 1. stop the mysql service # if there is a service, stop it like this # servicemysqldstop2. when starting the mysql service, add the ignore authorization option # mysqld_safe -- skip-grant-tables & amp; 3. use the mysql client to directly connect to the console # mys
Yesterday I forgot the password of the root user of the mysql database on a server. after searching and solving the problem, I learned that I could reset the root password as follows:
1. stop the mysql service
- # If there is a service, you can stop it like this
- # Service mysqld stop
2. add the ignore authorization option when starting the mysql service
- # mysqld_safe --skip-grant-tables &
3. use the mysql client to directly connect to the console
- # mysql
4. change the root account password on the mysql console
- mysql>use mysql;
- mysql>update user setpassword=password('root') where name='root' and host='localhost';
- mysql>\q
5. stop the mysql service and kill the mysql process.
6. start the mysql service in normal mode.
- # service mysqld start
Then, connect to the mysql client and enter the root password. in step 3, the root password has been reset to root. In fact, it's quite simple. well, record it for future reference.