本人認真刪除了root @ localhost用戶,也就是我後來發現mysql需要工作,現在我無法用root登錄,即使密碼正確。我試圖運行MySQL插件AFE模式:在mysql數據庫中恢復MySql root @ localhost用戶
/usr/bin/mysqld_safe --skip-grant-tables
,然後登錄電子作爲沒有密碼根進入MySQL數據庫,在那裏我應該執行:
create user [email protected];
然後:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' with grant option;
commit;
FLUSH PRIVILEGES;
exit
但是當我嘗試用上面的命令創建用戶時,我得到:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
有什麼建議如何解決這個問題?幫助是非常贊同的,謝謝!
編輯:解決方案
謝謝!這解決了我的問題:
INSERT INTO
mysql
。user
(Host
,User
,Password
,Select_priv
,Insert_priv
,Update_priv
,Delete_priv
,Create_priv
,Drop_priv
,Reload_priv
,Shutdown_priv
,Process_priv
,File_priv
,Grant_priv
,References_priv
,Index_priv
,Alter_priv
,Show_db_priv
,Super_priv
,Create_tmp_table_priv
,Lock_tables_priv
,Execute_priv
,Repl_slave_priv
,Repl_client_priv
,Create_view_priv
,Show_view_priv
,Create_routine_priv
,Alter_routine_priv
,Create_user_priv
,ssl_type
,ssl_cipher
,x509_issuer
,x509_subject
,max_questions
,max_updates
,max_connections
,max_user_connections
)VALUES( '%', '根', PASSWORD( 'NEW_PASSWORD_HERE'),「Y Y,'Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y' ,'Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y' 'Y','','','','','0','0','0','0');
要恢復事件和觸發器的權限,我不得不使用'all'特權訪問另一個用戶,幸運的是我有一個,但可能沒有這個特權是不可能的。
INSERT'他在'mysql.user'表中,設置'Grant_priv ='Y',Super_priv ='Y'',重啓,看看它做了什麼。 – Wrikken
我很擔心這隻會恢復現有root用戶的權限,但我需要重新創建root @ localhost – shiro
@ user1850912看看我的答案是否會對您有所幫助。 –