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 MySQL forgetting password

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article will explain in detail how to solve the problem of MySQL forgetting your password, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

1. Modify MySQL configuration file

First of all, we need to open the configuration file for MySQL. For Windows systems, the configuration file for MySQL is my.ini, which is in the default installation directory for MySQL; for MacOS systems, the configuration file name is my.cnf and its path is / etc/my.cnf.

Taking MacOS as an example, we need to add "skip-grant-tables" after [mysqld] in the configuration file, which means setting to skip permission verification, as shown in the following figure:

MacOS can edit the configuration file directly using the "sudo vim / etc/my.cnf" command.

Matters needing attention

If you cannot find the configuration file for MySQL in MacOS, you can create a my.cnf directly under the / etc directory and add the following:

[client] default-character-set=utf8 [mysqld] bind-address = 127.0.0.1 character-set-server=utf8 skip-grant-tables

Of course, if there are other configuration items, you can also modify them yourself.

two。 Restart MySQL

After modifying the configuration file, we need to restart the MySQL service for the configuration to take effect.

If it is a Windows system, we can shut down and then start MySQL by executing the command as follows:

Net stop mysql net start mysql

If it is a Linux system, you can restart it directly using the command:

Service mysql restart

If it is a Mac system, you can restart it through the interface, as shown below:

3. Set a new password

After restarting the service, we can use the command line tool to set the new password for MySQL. First, we enter the "mysql-u root-p" command to connect to the MySQL server. When the password box appears, you can log in by pressing enter directly, as shown below:

Next, we use the following command to set the new password:

Update user set password=password ('new password') where user='root'; flush privileges; quit

Matters needing attention

If an ERROR 1290 (HY000): The MySQL server is running with the-- skip-grant-tables option so it cannot execute this statement error occurs while performing this step. You need to execute the flush privileges command first, and then execute other commands.

About MySQL forgot password how to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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