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

How to restore the root account after mysql mistakenly deleted root

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

Share

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

System:

CentOS release 6.5 (Final)

Kernel:

2.6.32-431.el6.x86_64

MySQL version:

5.5.28-log Source distribution

Procedure:

1. Stop the mysql service

# service mysqld stop

two。 Enter mysql in safe mode

# mysqld_safe-- skip-grant-tables &

# mysql-u root-p\ the password is empty at this time

3. Rebuild root

Mysql > USE mysql

Mysql > INSERT INTO user (host,user,password)

-> VALUES ('localhost','root',password (' password'));\ the password here can be set later

4. Assign permissions to root users

Update user set Host='localhost',select_priv='y', insert_priv='y',update_priv='y',Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',super_priv='y' Create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y',create_user_priv='y',event_priv='y',trigger_priv='y',create_tablespace_priv='y' where user='root'

Mysql > FLUSH PRIVILEGES / / Refresh exit mysql, restart the mysql service, and then restore the root account.

Note: when assigning permissions to root users, Event_priv, Trigger_priv and Create_tablespace_priv permissions must be added, otherwise other users cannot be granted all privileges permissions even if root users are restored.

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