新聞中心
Redis會將用戶設(shè)置的密碼存儲在內(nèi)存中,在Redis重啟后,這些密碼就無從獲取了。當(dāng)Redis的密碼丟失時,情況就非常棘手了。

創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站制作、做網(wǎng)站與策劃設(shè)計,滁州網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十多年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:滁州等地區(qū)。滁州做網(wǎng)站價格咨詢:028-86922220
我們知道,如果Redis沒有相應(yīng)的密碼控制,就談不上安全了。因此,當(dāng)密碼丟失重啟后,我們必須立即解決問題,恢復(fù)Redis的原始密碼。
第一步:重啟Redis應(yīng)用服務(wù),使其具有操作權(quán)限,然后用”CONFIG GET”查看當(dāng)前Redis是否設(shè)置了密碼:
redis 127.0.0.1:6379> CONFIG GET requirepass
若返回結(jié)果為空,則無需處理,表明Redis是沒有設(shè)置密碼;若返回結(jié)果中有密碼內(nèi)容,則表明此密碼仍然存在,此時應(yīng)將Redis內(nèi)部的密碼內(nèi)容使用 “CONFIG SET” 設(shè)置為當(dāng)前需要使用的密碼:
redis 127.0.0.1:6379> CONFIG SET requirepass 123456
若返回OK表示設(shè)置成功,則可以正常使用Redis服務(wù)了。若返回結(jié)果不為OK表示操作失敗,可以使用” SHUTDOWN SAVE”命令將數(shù)據(jù)保存至本地文件,然后重啟服務(wù):
redis 127.0.0.1:6379> SHUTDOWN SAVE
第二步:進(jìn)入Redis的安裝目錄,找到redis.windows.conf文件,修改里面的兩個關(guān)鍵參數(shù):
# Require clients to issue AUTH before processing any other commands.
# This might be useful in environments in which you do not trust others
# with access to the host running redis-server.
#
# requirepass foobared
#
# Command Renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will be still avlable for internal-use tools
# but not avlable for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
將requirepass參數(shù)改為你想設(shè)置的密碼,可以自定義,比如:
# Require clients to issue AUTH before processing any other commands.
# This might be useful in environments in which you do not trust others
# with access to the host running redis-server.
#
requirepass 123456
#
# Command Renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will be still avlable for internal-use tools
# but not avlable for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
保存文件,重啟Redis服務(wù)后即可按照新設(shè)置的密碼登錄Redis。
當(dāng)Redis的密碼丟失重啟后,上述方法可以幫助我們解決困境,恢復(fù)Redis的原始密碼。
成都服務(wù)器托管選創(chuàng)新互聯(lián),先上架開通再付費。
創(chuàng)新互聯(lián)(www.cdcxhl.com)專業(yè)-網(wǎng)站建設(shè),軟件開發(fā)老牌服務(wù)商!微信小程序開發(fā),APP開發(fā),網(wǎng)站制作,網(wǎng)站營銷推廣服務(wù)眾多企業(yè)。電話:028-86922220
本文名稱:Redis密碼丟失重啟后的困境(redis重啟后密碼丟失)
轉(zhuǎn)載來于:http://fisionsoft.com.cn/article/dpgejdc.html


咨詢
建站咨詢
