Get the App
SLTechnology News&Howtos  ›  Database  › 

What if I forget the root password in Mysql 5.7?

Shulou Source: shulou.com Published: 2022-05-31 21:00:09 10月19日 Update

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.

Tags: Password how to do content more help good interest parameters guys buddies files articles knowledge articles can login reference login input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Tech Info Docker Microsoft MariaDB