Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if mysql forgot her password?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "mysql forgot the password how to do", the article explained the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "mysql forgot the password how to do" it!

# this method is based on version 5.7. Other versions should be roughly the same.

2. Modify the login settings of MySQL:

# vi / etc/my.cnf

Add a sentence to the paragraph of [mysqld]: skip-grant-tables

For example:

[mysqld]

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

Skip-grant-tables

Save and exit vi.

Service mysqld restart

There is no password to enter mysql at this time.

Mysql-u root-p directly enter

Modify password 5.7. password field is authentication_string

Note that version 5.7 passwords must have numbers, uppercase and lowercase letters, special symbols such as Yl19861212@

Can be used

ALTER USER USER () IDENTIFIED BY 'Yl19861212@'; or

Update user set authentication_string=password ('Yl19861212@') where user=root

And then flush privileges

Exit mysql

Exit

Restart the service

Service mysql restart

At this point, the password has been changed.

Skip-grant-tables needs to be annotated in my.cnf.

Otherwise, the password will be set to empty again when you restart.

Restore 5.1database to 5.7environment, because the user table structure is inconsistent, user authentication needs to be bypassed.

Skip-grant-tables

Otherwise, the service will not be started.

Cross-version restore recommends mysqldump logical backup and then exports user information to restore

Thank you for your reading, the above is the "mysql forgot the password how to do" the content, after the study of this article, I believe you forget the password on mysql how to do this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report