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

How to solve the problem of forgetting root password in mysql

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

Share

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

Editor to share with you how to solve the problem of forgetting root password in mysql, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

Under Windows, if the MySQL password forgets the root password, you cannot log in, as shown in the following figure

What to do at this time? we can only reset the root password.

1. Open the task manager to see if the MySql service is started, and if so, stop it first

two。 Find the my.ini file in the MySql directory

3. Open the file, find the [mysqld] in it, then add skip-grant-tables under this file, and save the file after adding.

4. Re-enter the task manager to start the MySQL service

5. Run cmd as an administrator

Note that cmd must be run as an administrator in this way, not by typing cmd with win+R, or there will be an error that "'mysql' is not an internal or external command, nor is it a runnable program or batch file".

6. Enter mysql-u root-p to log in without a password. Enter directly when password: appears.

7. Access the mysql database:

Mysql > use mysql;Database changed

8. Set a new password for root users: mysql > update user set password=password ("123456") where user= "root"

Hint: Query OK, 1 rows affected (0.04 sec) Rows matched: 1 Changed: 1 Warnings: 0

PS:123456 is a new password, and users can change it to their own password according to their own needs.

9. Open the previous my.ini file to delete the line "skip-grant-tables" that was added

10. Open Task Manager and restart the MySQL service. Then we can connect to the database with the password "123456" we just set.

The root password of Mysql was modified successfully!

The above is all the contents of this article entitled "how to solve the problem of forgetting root password in mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.

Share To

Database

Wechat

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

12
Report