mysql5.7 誤刪管理員root賬戶


1.停止數據庫,並在mysql配置文件my.cnf中添加skip-grant-tables參數到[mysqld]配置塊中

2. 執行 systemctl start mysqld

3. 執行 mysql 

4.創建 root 用戶並賦權限,並修改root密碼

insert into user set user='root',ssl_cipher='',x509_issuer='',x509_subject='';

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' where user='root';

update user set authentication_string=password('123456') where user='root';

5. 刷新 退出mysql

flush privileges;
quit

6.注釋掉skip-grant-tables參數,重啟數據庫

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM