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 I forget my mysql root password?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "what to do if mysql root password is forgotten". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and go deep into it slowly to study and learn "what to do if mysql root password is forgotten" together!

I. One of the ways to recover MySQL passwords

If you forget MySQL's root password, you can reset it as follows:

1. KILL MySQL processes in the system;

killall -TERM mysqld

2. Start MySQL without checking permissions with the following command:

safe_mysqld --skip-grant-tables &

3. Then log in to MySQL as root with an empty password;

mysql -u root

4. Change the password of root user;

mysql> update mysql.user set password=PASSWORD ('new password') where User ='root ';

mysql> flush privileges;

mysql> quit

Restart MySQL and log in with the new password.

II. MySQL password recovery method 2

It is possible that your system does not have safe_mysqld program (such as my current ubuntu operating system, apt-get installed mysql) , the following method can be restored

1. Stop mysqld;

/etc/init.d/mysql stop

(You may have other ways, but just stop mysqld anyway)

2. Start MySQL without checking permissions with the following command:

mysqld --skip-grant-tables &

3. Then log in to MySQL as root with an empty password;

mysql -u root

4. Change the password of root user;

mysql> update mysql.user set password=PASSWORD('newpassword') where User='root';

mysql> flush privileges;

mysql> quit

Restart MySQL

/etc/init.d/mysql restart

You can log in with your new password.

Thank you for reading, the above is the content of "mysql root password forgotten how to do", after the study of this article, I believe that everyone has a deeper understanding of mysql root password forgotten how to do this problem, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

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

Servers

Wechat

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

12
Report