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 mysql forgets the root password?

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

Share

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

This article mainly introduces mysql forget root password how to do, has a certain reference value, interested friends can refer to, I hope you read this article after a great harvest, the following let Xiaobian take you to understand.

1. Close mysql service

Click here to fold or open

net stop mysql57

2. Execute mysqld

- Open cmd window and switch to mysql installation directory

Click here to fold or open

cd C:\Program Files\MySQL\MySQL Server 5.7\bin

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --skip-grant-tables

3. New cmd, login root

- No password, just enter.

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p

Enter password:

4. Change root password

Click here to fold or open

mysql> use mysql;

Database changed

mysql> update mysql.user set authentication_string=password('root') where user='root' ;

Query OK, 1 row affected, 1 warning (0.01 sec)

Rows matched: 1 Changed: 1 Warnings: 1

mysql> flush privileges;

Query OK, 0 rows affected (0.02 sec)

5. Log in to root with new password

Click here to fold or open

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p

Enter password: ****

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show database;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that

corresponds to your MySQL server version for the right syntax to use near 'datab

ase' at line 1

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| fortress |

| mysql |

| performance_schema |

| python |

| stuman |

| stuman2 |

| sys |

| www |

+--------------------+

9 rows in set (0.00 sec)

Thank you for reading this article carefully. I hope that the article "mysql forgets the root password" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you more, pay attention to the industry information channel, and more relevant knowledge is waiting for you to learn!

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