I acciden开发者_开发知识库tally removed all privileges for root user. How can I recover it ?
Check out this part of the MySQL-Documentation, they've dedicated a whole chapter to this: http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html
First, start MySQL with --skip-grant-tables
Next, run the following query:
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'
Finally, run FLUSH PRIVILEGES;
and restart MySQL
If you need to reset the password as well, follow the instructions in the link above.
精彩评论