Reset the password of Mysqlroot in CentOS

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.