新聞中心
在安裝軟件時,需要用到Mysql數據庫,要在里面建一個數據庫,及相應的用戶,執(zhí)行建庫腳本,很順利,數據庫成功建好,但在執(zhí)行用戶授權時錯誤就產生了:

邳州網站建設公司創(chuàng)新互聯(lián)建站,邳州網站設計制作,有大型網站制作公司豐富經驗。已為邳州數千家提供企業(yè)網站建設服務。企業(yè)網站搭建\外貿營銷網站建設要多少錢,請找那個售后服務好的邳州做網站的公司定做!
- createdatabasecactidb;
- grantalloncactidb.*toroot@localhost;
- grantalloncactidb.*tocactiuser;
本來這是沒什么的,但我之前已經把root@localhost這個用戶給刪除了,我只留下了用戶名為root,host是%的用戶,而我平常的操作為了方便都只是用root在本機登錄的,我的mysql也只監(jiān)聽127.0.0.1這個地址,結果一執(zhí)行grantalloncactidb.*toroot@localhost;這個命令立即完蛋了,我在本機用root登錄就只能是root@localhost這個用戶的權限,而不是一平常用的root@%這個用戶,但root@localhost基本就是沒有權限,按照Mysql的授權機制,我只有在其它主機登錄才可使用root@%這個用戶,而我根本就不可能從其它地址登錄,這下把我給急壞了。由于嚴格的防火墻策略,我是不可能開放mysql的端口的。后來在網上找了相關資料,用以下方法解決了這個問題:
1、關閉mysql服務:servicemysqldstop。
2、./mysqld_safe--skip-grant-tables重新啟動mysql。
3、重新使用root登錄,此時不需要密碼。
4、登錄后刪除root@local這個用戶。
5、用ps查到mysqld進程,并用kill中止mysql進程。
6、重新啟動mysql進程:servicemysqldstart。
7、當然使用這個方法也可重置root密碼:setpasswordforroot=password(yourpass');
8、或者也可以重置root用戶權限。
- updatedbsetSelect_priv='Y'whereuser='root';
- updatedbsetInsert_priv='Y'whereuser='root';
- updatedbsetUpdate_priv='Y'whereuser='root';
- updatedbsetDelete_priv='Y'whereuser='root';
- updatedbsetCreate_priv='Y'whereuser='root';
- updatedbsetDrop_priv='Y'whereuser='root';
- updatedbsetReferences_priv='Y'whereuser='root';
- updatedbsetGrant_priv='Y'whereuser='root';
- updatedbsetIndex_priv='Y'whereuser='root';
- updatedbsetAlter_priv='Y'whereuser='root';
- updatedbsetCreate_tmp_table_priv='Y'whereuser='root';
- updatedbsetLock_tables_priv='Y'whereuser='root';
- updatedbsetCreate_view_priv='Y'whereuser='root';
- updatedbsetGrant_priv='Y'whereuser='root';
- updatedbsetShow_view_priv='Y'whereuser='root';
- updatedbsetCreate_routine_priv='Y'whereuser='root';
- updatedbsetAlter_routine_priv='Y'whereuser='root';
- updatedbsetExecute_priv='Y'whereuser='root';
再把mysql.user表里root用戶的所有字段都置為'Y'。
注意:使用--skip-grant-tables啟動mysql時不可使用grant命令的,所以只有我們手工來設置權限表了。
關于MySQL權限表的問題就介紹到這里,如果大家想了解更多關于MySQL數據庫的知識,不妨到這里看一下:http://database./mysql/,一定會讓您滿意的哦!
【編輯推薦】
- 利用mysql的audit審計功能記錄用戶操作信息
- MySQL索引背后的數據結構及算法之索引實現
- Facebook對MySQL依賴的后果將是“比死還糟
- 詳解Discuz_WIN7_Apache_MySQL_PHP平臺搭建
- MySQL錯誤:Can'tconnecttoMySQLserver(10060)
網站欄目:MySQL數據庫用戶權限表丟失的解決方案
本文鏈接:http://fisionsoft.com.cn/article/cdjgppc.html


咨詢
建站咨詢
