我意外删除了root用户的所有权限。我怎样才能恢复它?
答案 0 :(得分:1)
查看MySQL文档的这一部分,他们专门用了整整一章: http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html
答案 1 :(得分:1)
首先,start MySQL with --skip-grant-tables
接下来,运行以下查询:
UPDATE mysql.user SET
Select_priv = 'Y',
Insert_priv = 'Y',
Update_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',
Alter_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',
max_questions = 0,
max_updates = 0,
max_connections = 0,
max_user_connections = 0
WHERE user = 'root'
最后,运行FLUSH PRIVILEGES;
并重启MySQL
如果您还需要重置密码,请按照上面链接中的说明进行操作。