mysql誤刪root用戶恢復(fù)方法
裝完數(shù)據(jù)庫(kù)清理一些默認(rèn)賬號(hào)的時(shí)候不小心把root刪除了,flush privileges 之后的新 root 忘了grant任何權(quán)限,查看mysqld選項(xiàng)里面有個(gè) −−skip-grant-tables
#/usr/libexec/mysqld --verbos --help
mysql5.5手冊(cè)說(shuō)明如下
--skip-grant-tables
This option causes the server to start without using the privilege system at all, which gives anyone with access to the server unrestricted access to all databases. You can cause a running server to start using the grant tables again by executing mysqladmin flush-privileges or mysqladmin reload command from a system shell, or by issuing a MySQL FLUSH PRIVILEGES statement after connecting to the server. This option also suppresses loading of plugins, user-defined functions (UDFs), and scheduled events. To cause plugins to be loaded anyway, use the --plugin-load option.
--skip-grant-tables is unavailable if MySQL was configured with the --disable-grant-options option. See Section 2.10.2, “Typical configure Options”.
mysqld_safe是Unix/Linux系統(tǒng)下的MySQL服務(wù)器的一個(gè)啟動(dòng)腳本。這個(gè)腳本增加了一些安全特性,會(huì)在啟動(dòng)MySQL服務(wù)器以后繼續(xù)監(jiān)控其運(yùn)行情況,并在出現(xiàn)錯(cuò)誤的時(shí)候重新啟動(dòng)服務(wù)器。后臺(tái)啟動(dòng)mysql
#mysqld_safe --skip-grant-tables &
如果沒(méi)有root賬戶就添加一個(gè)
INSERT INTO user SET User='root',Host='localhost',ssl_cipher='',x509_issuer='',x509_subject='';
直接輸入mysql連接并添加權(quán)限,這時(shí)候是不能使用grant命令的,只能用update
UPDATE 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',authentication_string='' WHERE User='root';
注意我用的是mysql是5.5版本,可能操作過(guò)程中sql語(yǔ)句或其他地方有不同,語(yǔ)句執(zhí)行完畢之后需要flush privileges ,還可能要重新登錄才行。
- MySQL8中誤刪數(shù)據(jù)恢復(fù)的7種方法完整指南
- mysql數(shù)據(jù)被誤刪的恢復(fù)方案以及預(yù)防措施
- MySQL數(shù)據(jù)誤刪或者誤更新如何恢復(fù)詳細(xì)步驟(一看就會(huì))
- Mysql恢復(fù)誤刪庫(kù)表數(shù)據(jù)完整場(chǎng)景演示
- MySQL數(shù)據(jù)庫(kù)誤刪恢復(fù)的超詳細(xì)教程
- 關(guān)于mysql數(shù)據(jù)庫(kù)誤刪除后的數(shù)據(jù)恢復(fù)操作說(shuō)明
- mysql 誤刪除ibdata1之后的恢復(fù)方法
- MySQL誤刪數(shù)據(jù)或者丟失?這6種方案能幫你快速恢復(fù)!
相關(guān)文章
MySQL中數(shù)據(jù)類型相關(guān)的優(yōu)化辦法
這篇文章主要介紹了MySQL中數(shù)據(jù)類型相關(guān)的優(yōu)化辦法,包括使用多列索引等相關(guān)的優(yōu)化方法,需要的朋友可以參考下2015-07-07
Mac?Homebrew安裝的MySQL無(wú)法遠(yuǎn)程登錄的解決
這篇文章主要介紹了Mac?Homebrew安裝的MySQL無(wú)法遠(yuǎn)程登錄的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-11-11
Mysql5.7忘記root密碼怎么辦(簡(jiǎn)單且有效方法)
本文給大家分享一個(gè)快速且簡(jiǎn)單的方法來(lái)解決Mysql5.7忘記root密碼問(wèn)題,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2017-02-02
mysql too many open connections問(wèn)題解決方法
這篇文章主要介紹了mysql too many open connections問(wèn)題解決方法,其實(shí)是max_connections配置問(wèn)題導(dǎo)致,它必須在[mysqld]下面才會(huì)生效,需要的朋友可以參考下2014-05-05
MySQL 視圖 第1349號(hào)錯(cuò)誤解決方法
把下面SQL里的SELECT單獨(dú)執(zhí)行,沒(méi)有問(wèn)題,但是用來(lái)CREATE VIEW 就報(bào)錯(cuò)了.2008-03-03
mysql導(dǎo)入sql文件報(bào)錯(cuò) ERROR 2013 2006 2002
今天在做項(xiàng)目的時(shí)候遇到個(gè)問(wèn)題,就是往mysql里導(dǎo)入sql文件的時(shí)候總是報(bào)ERROR 2013 2006 2002,研究了一番才找到解決辦法,這里記錄下來(lái)分享給大家2014-11-11
MySQL存儲(chǔ)過(guò)程中使用WHILE循環(huán)語(yǔ)句的方法
這篇文章主要介紹了MySQL存儲(chǔ)過(guò)程中使用WHILE循環(huán)語(yǔ)句的方法,實(shí)例分析了在MySQL中循環(huán)語(yǔ)句的使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07

