Mysql forgot root Password handling method

Source: Internet
Author: User
Tags mysql command line

First, change the my.cnf configuration file

1. Edit the/etc/my.cnf configuration file with the command, namely: VIM/ETC/MY.CNF or VI/ETC/MY.CNF

2. Add skip-grant-tables under [mysqld] , then save and exit

3. Restart MySQL services: Servicemysqld Restart

Second, change the root user name

1. After reboot, execute MySQL command to enter MySQL command line

2. Change the root user password

mysql> UPDATE mysql.user SET password=password (' New password ') where user= ' root ';
mysql> flush Privileges;
Mysql> exit

3. Comment out the skip-grant-tables in the/etc/my.cnf, and then restart MySQL, which is:service mysqld Restart

Okay, now you can log in with the new root password.

Mysql forgot root Password handling method

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.