In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains how to solve the problem of Linux MySQL forgetting root password, the content is clear, interested friends can learn, I believe it will be helpful after reading.
When using the MySQL database, due to some reasons, we have not logged in to MySQL for a long time, or because the completion of the work handover is not high, the login password of the database root is forgotten, how to solve it?
I. change the my.cnf configuration file
1. Edit the / etc/my.cnf configuration file with the command, that is, vim / etc/my.cnf or vi / etc/my.cnf or nano / etc/my.cnf
two。 Add skip-grant-tables under [mysqld], then save and exit
3. Restart the mysql service: service mysqld restart
Change the root user name
1. After restarting, execute the mysql command to enter the mysql command line
2. Modify the password of root user
MySQL > UPDATE mysql.user SET Password=PASSWORD ('new password') where USER='root'
MySQL > flush privileges
MySQL > exit
Note: the above version is used before 5.7. there is no Password field in the version after 5.7. the password field has been changed to authentication_string.
Mysql > update mysql.user set authentication_string=password ('root123456') where user='root'; # password changed successfully
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
Mysql > flush privileges; # effective immediately
Query OK, 0 rows affected (0.00 sec)
Mysql > quit
Bye
N > mysql-u *-p # successfully logged in with this user.
Enter password: *
...
Mysql >
Note: in versions later than 123456, the password should not be too simple, such as 123456, otherwise the following error will be reported: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements.
At this point, either make the password more complex, or modify the configuration:
This is actually related to the value of validate_password_policy. Validate_password_policy has the following values: the default is 1, that is, MEDIUM, so the password you set at the beginning must match the length and must contain numbers, lowercase or uppercase letters, and special characters. Sometimes, just to test it myself, I don't want the password to be so complicated. For example, I just want to set the password for root to 123456. Two global parameters must be modified: first, modify the value mysql > set global validate_password_policy=0;Query OK of the validate_password_policy parameter, 0 rows affected (0.00 sec) 12validate_password_length (password length) parameter defaults to 8, we modify it to 1mysql > set global validate_password_length=1;Query OK, 0 rows affected (0.00 sec) 124.After completion, execute the password change statement again to successfully mysql > alter user 'root'@'localhost' identified by' 123456'. Query OK, 0 rows affected (0.00 sec)
3. Finally, comment out the skip-grant-tables in / etc/my.cnf, and then restart mysql, that is, service mysqld restart
OK, now we can log in to MySQL using root's new password.
After reading the above content, do you have a better understanding of how to solve the problem of Linux MySQL forgetting root password? if you want to learn more, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.