mysql誤刪root用戶恢復(fù)方法_MySQL教程
推薦:MySQL編程中的6個(gè)實(shí)用技巧每一行命令都是用分號(hào)(;)作為結(jié)束 對(duì)于MySQL,第一件你必須牢記的是它的每一行命令都是用分號(hào)(;)作為結(jié)束的,但當(dāng)一行MySQL被插入在PHP代碼中時(shí),最好把后面的分號(hào)省略掉,例如: 代碼如下: mysql_query(INSERT INTO tablename(first_name,last_name)VALUES('$first_na
裝完數(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 ,還可能要重新登錄才行。
分享:Centos中徹底刪除Mysql(rpm、yum安裝的情況)我用的centos6,mysql讓我整出了各種問(wèn)題,我想重裝一個(gè)全新的mysql,yum remove mysql-server mysql之后再install并不能得到一個(gè)干凈的mysql,原來(lái)的/etc/my.cnf依然沒(méi)變,datadir里面的數(shù)據(jù)已沒(méi)有任何變化,手動(dòng)刪除/etc/my.cnf,/usr/lib/mysql,/usr/share/mysql,
- MySQL編程中的6個(gè)實(shí)用技巧
- Centos中徹底刪除Mysql(rpm、yum安裝的情況)
- Mysql修改datadir導(dǎo)致無(wú)法啟動(dòng)問(wèn)題解決方法
- mysql 查詢重復(fù)的數(shù)據(jù)的SQL優(yōu)化方案
- mysql的左右內(nèi)連接用法實(shí)例
- mysql中You can’t specify target table for update in FROM clau
- MySQL查詢和修改auto_increment的方法
- MySQL中的if和case語(yǔ)句使用總結(jié)
- Centos5.5中安裝Mysql5.5過(guò)程分享
- /var/log/pacct文件導(dǎo)致MySQL啟動(dòng)失敗的案例分享
- MySQL中在查詢結(jié)果集中得到記錄行號(hào)的方法
- CentOS下php使用127.0.0.1不能連接mysql的解決方法
MySQL教程Rss訂閱編程教程搜索
MySQL教程推薦
- 如何修改mysql數(shù)據(jù)庫(kù)的max_allowed_packet參數(shù)
- Mysql,phpmyadmin密碼忘了怎么辦
- 網(wǎng)站模板:以數(shù)據(jù)庫(kù)字段分組顯示數(shù)據(jù)的sql語(yǔ)句
- SQL字符型字段按數(shù)字型字段排序?qū)崿F(xiàn)方法
- MySQL 替換某字段內(nèi)部分內(nèi)容的UPDATE語(yǔ)句
- Win7 系統(tǒng)上安裝SQL Server 2008圖解教程
- windows下重啟mysql的方法
- 通過(guò)mysqladmin遠(yuǎn)程管理mysql的方法
- mysql給用戶添加查詢權(quán)限
- mysql數(shù)據(jù)庫(kù)ROOT賬號(hào)權(quán)限丟失問(wèn)題解決方法
猜你也喜歡看這些
- 揭秘SQL Server開(kāi)發(fā)中需要注意的十個(gè)問(wèn)題
- 談SQL Data Services將成為云中完整的數(shù)據(jù)庫(kù)
- 總結(jié)經(jīng)典常用的SQL語(yǔ)句(1)
- 怎樣解決SQL Server數(shù)據(jù)庫(kù)權(quán)限沖突
- Win7系統(tǒng)安裝MySQL5.5.21圖解教程
- 如何快速生成100萬(wàn)不重復(fù)的8位編號(hào)
- SQL Server 2008網(wǎng)絡(luò)協(xié)議深入理解
- 如何解決MySQL 5數(shù)據(jù)庫(kù)連接超時(shí)問(wèn)題
- 淺談SQL將挑戰(zhàn)操作系統(tǒng)安全
- 解析最基本的sql語(yǔ)句操作
- 相關(guān)鏈接:
- 教程說(shuō)明:
MySQL教程-mysql誤刪root用戶恢復(fù)方法
。