无法在MYSQL中完全恢复root - 无法GRANT ALL

时间:2016-11-23 22:43:23

标签: mysql

不知怎的,我在mysql中丢失了root,我正在尝试恢复它。

我使用--skip-grant-tables选项将root插入到用户表中,然后运行

UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';

然后我定期启动mysql而不使用--skip-grant-tables选项 这就是我所看到的:

/usr/java/ep622_svn => mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.17 MySQL Community Server (GPL)

mysql> GRANT ALL ON *.* TO 'root'@'localhost';
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

1 个答案:

答案 0 :(得分:-1)

此链接有助于: https://dba.stackexchange.com/questions/97439/how-do-i-give-rootlocalhost-permission-to-grant-privileges-in-mysql

需要在运行--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',
Create_tablespace_priv='Y'
WHERE user='root';
FLUSH PRIVILEGES;