It is often necessary to help customers install Mysql. sometimes the customer's Mysql has been installed, and the password is forgotten. This article mainly introduces how to enter Mysql and reset the password without knowing the password of Mysqlroot. Step 1: modify the Mysql configuration file [root @ liama01 ~] # Vi/etc/my. step 2 of the cnfMysql configuration file: After Mysql is restarted, mysql-uroo often needs to help the customer install Mysql. sometimes the customer's Mysql has been installed and forgets the password, how to enter Mysql and reset the password without knowing the Mysql root password.
Step 1: modify the Mysql configuration file
[Root @ liama01 ~] # Vi/etc/my. cnf
Mysql configuration file
Step 2: restart Mysql and run the mysql-uroot-p command to log on to Mysql and change the password.
Restart Mysql in Linux:
[root@liama01 ~]# service mysqld restart
Restart Mysql in windows and then restart Mysql in service management.
Log on to Mysql in Linux:
[root@liama01 ~]# mysql -uroot -pEnter password:
Press enter to log on.
mysql> use mysqlmysql> update user set password=PASSWORD('123456') WHERE user="root";mysql> flush privileges;
After the command is executed, change the Mysql root password to "123456"
Remember to remove the skip-grant-tables configuration line from the configuration file.