mysql5.7 forgot root password perfect solution

Source: Internet
Author: User

Programme one:
1. Stop MySQL
Service MySQL Stop

2. Add parameters to MySQL config file '/usr/local/mysql/my.cnf '
--skip-grant-tables

3. Start MySQL
Service MySQL Start

4. Execute a command to enter MySQL
Mysql

5. Update password Note This is the way to mysql5.7.
Mysql>update Mysql.user Set Authentication_string=password (' 123456 ') where user= ' root ' and Host = ' localhost ';

    5.7之前的应该这样改:    update user set password=password("123") where user="root";

6. Remove the configuration file add parameter '--skip-grant-tables ', restart MySQL, OK

Scenario Two:
Reference: http://www.jb51.net/article/77858.htm
1[[email protected] ~]# service MySQL stop
2[[email protected] ~]# mysqld_safe--skip-grant-tables &
3[[email protected] ~]# mysqld_safe--skip-grant-tables--skip-networking &
4[[email protected] ~]# mysql-p
5mysql> Update Mysql.user Set Authentication_string=password (' 123qwe ') where user= ' root ' and Host = ' localhost ';
6mysql> flush Privileges;
Mysql> quit;
7[[email protected] ~]# service MySQL restart

mysql5.7 forgot root password perfect solution

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.