今天同事,調(diào)整mysql安全,在刪除用戶的時候誤刪了 root@localhost,后來加進(jìn)去了,但是在登錄發(fā)現(xiàn)數(shù)據(jù)庫很多庫都沒有了,頓時懵逼,考慮恢復(fù)數(shù)據(jù),稍后我看到了,想起當(dāng)年也出現(xiàn)過類似情況,主要是因?yàn)閞oot用戶沒有權(quán)限,所以跳過授權(quán)表,經(jīng)過查詢權(quán)限,真的缺少,所以將其都由N改為Y ,在次測試,OK,以下是處理步驟。
創(chuàng)新互聯(lián)建站是一家專業(yè)提供祥符企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè)、H5頁面制作、小程序制作等業(yè)務(wù)。10年已為祥符眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站設(shè)計公司優(yōu)惠進(jìn)行中。第一步,跳過授權(quán)表登錄mysql
1、pkill 停止 實(shí)例進(jìn)程 2、mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables & 3、mysql -S /data/3306/mysql.sock 4、UPDATE mysql.user SET password=PASSWORD('oldboy123') WHERE user='root' and host='localhost'; 5、flush privileges; 6、kill掉mysqld_safe 進(jìn)程 7、/etc/init.d/msyql start 正常啟動 登錄即可 mysql -uroot -poldboy123第二步、修改權(quán)限(也可以初始化root密碼)
mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | oldboy_gbk | | performance_schema | | qiuyuetao | | test | +--------------------+ 6 rows in set (0.00 sec) mysql> show tables; +---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | db | | event | | func | | general_log | | help_category | | help_keyword | | help_relation | | help_topic | | host | | ndb_binlog_index | | plugin | | proc | | procs_priv | | proxies_priv | | servers | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 24 rows in set (0.00 sec) 更新的MYSQL.USER表的所有字段中為N的為Y就可以了。 update user set Select_priv ='Y' where user = 'root'; update user set Insert_priv ='Y' where user = 'root'; update user set Update_priv ='Y' where user = 'root'; update user set Delete_priv ='Y' where user = 'root'; update user set Create_priv ='Y' where user = 'root'; update user set Drop_priv ='Y' where user = 'root'; update user set Reload_priv ='Y' where user = 'root'; update user set Shutdown_priv ='Y' where user = 'root'; update user set Process_priv ='Y' where user = 'root'; update user set File_priv ='Y' where user = 'root'; update user set Grant_priv ='Y' where user = 'root'; update user set References_priv ='Y' where user = 'root'; update user set Index_priv ='Y' where user = 'root'; update user set Alter_priv ='Y' where user = 'root'; update user set Show_db_priv ='Y' where user = 'root'; update user set Super_priv ='Y' where user = 'root'; update user set Create_tmp_table_priv ='Y' where user = 'root'; update user set Lock_tables_priv ='Y' where user = 'root'; update user set Execute_priv ='Y' where user = 'root'; update user set Repl_slave_priv ='Y' where user = 'root'; update user set Repl_client_priv ='Y' where user = 'root'; update user set Create_view_priv ='Y' where user = 'root'; update user set Show_view_priv ='Y' where user = 'root'; update user set Create_routine_priv ='Y' where user = 'root'; update user set Alter_routine_priv ='Y' where user = 'root'; update user set Create_user_priv ='Y' where user = 'root'; update user set Event_priv ='Y' where user = 'root'; update user set Trigger_priv ='Y' where user = 'root';另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。