How to solve mysql forgotten password

foreword

Blogger's Personal Community: Development and Algorithm Learning Community

Blogger Profile: Killing Vibe's Blog

Everyone is welcome to join and exchange and learn together~~

1. Open MySQL (if you can open it, please skip this step)

The first one: After installing MySQL, MySQL provides your client program

insert image description here

The second method: log in through the command line, win+R

insert image description here

Note : In the second method, if the command line shows that mysql cannot be found, it is because there is no environment variable configured . We can find it in the bin directory under the MySQL installation path. By default, it is in the path shown in the figure:

insert image description here
Just modify the environment variables, if not, you can read the blogger's previous article:

Set environment variable graphics

As follows:

insert image description here

2. Password-free login (you can start from this step if you forget the password)

1. Find the configuration file of mysql

insert image description here

Note: If you can't find it, check the hidden items, because the ProgramData folder is hidden by default

insert image description here

2. Open the my.ini file

insert image description here
3. Find the place shown in the figure and enter skip-grant-tables

insert image description here

4. Go down and find this place and enter utf8mb4 (remember to save and then close)

insert image description here

5. Close the mysql service and open it again. At this time, we can log in to mysql directly without a password

insert image description here

6. Just press Enter to log in

insert image description here

3. Change password

1. Enter the following code and press Enter

update mysql.user set authentication_string = password(‘1’) where user=‘root’;

insert image description here

Your password will be changed to 1~

2. If you don’t want to log in without password, you can comment out the skip-grant-tables in the my.ini file, restart the mysql service, and log in with the new password

Summarize

The above is the process of mysql password-free login and password modification. If it is helpful, don’t forget to pay attention. Bloggers continue to share dry goods with pictures and texts~~

Guess you like

Origin blog.csdn.net/qq_43575801/article/details/127520990