Mysql 5.7 Liunx forgot password remedy

Source: Internet
Author: User
Tags mysql login

Linux under the root password of MySQL forgot to solve the party


1. To modify MySQL login settings
# VIM/ETC/MY.CNF
In the paragraph [mysqld], add one sentence:

Skip-grant-tables

For example:

[Mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/Mysql.sockskip 

2. Restart MySQL

Systemctl Restart Mysqld

3. You can now login MySQL without a password

Mysqld-uroot          //Direct Login

4. Update password

* Note that there is no password field in the user table in the new MySQL database , and it becomes authentication_string

mysql> Update Mysql.user Set Authentication_string=password (' XXXXXXXX ') where user= ' root ';
mysql> Flush privileges;mysql> quit;

5. Re-modify MySQL login settings

Add the first step to Skip-grant-tables's deletion

6. Restart Musql

Systemctl Restart Mysqld

Mysql 5.7 Liunx forgot password remedy

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.