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

MySQL 5.7 change your password after you forget it

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Modify login settings

Vim / etc/my.cnf # or / etc/mysql/my.cnf [mysqld] skip-grant-tables # added

2. Restart the mysql service

3. Log in directly to mysql and change the password.

This is the save password field in update mysql.user set authentication_string=password ("new password") where User='root'; # 5.7. desc first take a look at the save password field. Other versions are generally modified as follows: # mysql > UPDATE mysql.user SET Password = password ('new-password') WHERE User =' root'; # if you encounter an error You must reset your password using ALTER USER statement before executing this statement. The reason is that to change the password or the password has expired, you need to execute 1. Alter user user () identified by "123456"; after changing the password, the problem is usually solved. If not, see step 2 below. ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; # set the password to never expire, change back to the default method alter user' root'@'localhost' password expire default 3. Either set global default_password_lifetime=0 or write it directly in the configuration file. An expiration time of 0 means it will never expire, and it will take effect globally. The above method is recommended that only specific user passwords do not expire flush privileges; # this step must be performed to change passwords using update or # tested plus skip-grant-tables cannot perform the following operations set password=passwprd ('new password'); # No need to refresh the authorization table, full format SET PASSWORD FOR 'root'@'localhost'=PASSWORD (' newpassword')

4. Modify the configuration file

Delete

Skip-grant-tables

Restart the service

Method 2:

Stop the mysql service

Use-- skip-grant-tables to start the database, ignoring authorization login verification

Mysqld_safe-- skip-grant-tables-- user=mysql & mysql # change the password after logging in. Add-S "SOCKET" to multiple instances.

3. Shut down the database and restart

Mysqladmin-uroot-paired newpassword 'shutdown # close, or kill with kill,pkill

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