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 the root password in Mysql 5.7?

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

Share

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

This article introduces how to forget the root password in Mysql 5.7. the content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Modify the mysql parameter file:

[root@test ~] # vi / etc/my.cnf

In

[mysqld] add the following:

Skip-external-locking

Save.

[root@test ~] # service mysqld restart

MySQL server PID file could not be found! [FAILED]

You can log in without a password:

[root@test] # mysql-uroot-p

Enter password:

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

Your MySQL connection id is 3

Server version: 5.7.19-log 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 [(none)] > USE mysql

Database changed

MySQL [mysql] > update user set authentication_string=password ('test') where user='root' and Host =' 127.0.0.1'

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

Rows matched: 1 Changed: 1 Warnings: 1

MySQL [mysql] > update user set authentication_string=password ('test') where user='root' and Host ='%'

Query OK, 0 rows affected, 1 warning (0.00 sec)

Rows matched: 0 Changed: 0 Warnings: 1

The modification is complete.

Then put the one that was originally in / etc/my.cnf behind [mysqld]

Skip-external-locking

Get rid of it.

You need to enter a password to log in:

[root@test] # mysql-uroot-p

Enter password:

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

Your MySQL connection id is 4

Server version: 5.7.19-log 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 [(none)] >

So much for sharing about how to forget your root password in Mysql 5.7.I hope the above can help you and learn more. 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