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

Delete the user in mysql by mistake, how to reset the root account and password

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

Share

Shulou(Shulou.com)06/01 Report--

When practicing the mysql statement, you use delete to delete all users in the database, including root users. And carried out the flush privileges; at this time found that re-login mysql has been unable to log in normally. For this, we need to reset the root account and root password. The specific steps are as follows:

Delete user actions:

Mysql > delete frommysql.user; Delete all users mysql > flushprivileges

First of all, break all the links associated with the database to prevent the loss of data when the database is restarted.

[root@node1 ~] # service mysqld stop

Modify database configuration file

[root@node1 ~] # vim / etc/my.cnf

The contents under [mysql] in the configuration file

In [mysql]

Add "skip-grant-tables" to the next line

Save and exit, restart the mysql database

[root@node1mysql] # mysqlmysql > insertinto mysql.user (host, user, password,sll_cipher,x509_issuer,x509_subjec) values ('localhost',' root',password ('123456'),',')

Exit the database, make changes to the mysql.cnf configuration file, and delete the newly added lines. Just restart the database.

[root@node1 ~] # service mysqld restart

You can complete the addition of mysqlroot users!

The second way is not to modify the configuration file of mysql.

Service mysqld stop / / stop mysql database service mysqld_safe--skip-grant-tables-- skip-networking

In addition, terminal

Mysqlmysql > insertinto mysql.user (host, user, password,sll_cipher,x509_issuer,x509_subjec) values ('localhost',' root',password ('123456'),',')

You can complete the addition of database root users!

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