今天服務(wù)器安裝了redis,為了安全設(shè)置一下訪問redis-server的密碼。
一、查找redis.conf文件
我們服務(wù)器已經(jīng)安裝了redis,現(xiàn)在通過命令查看下redis的進(jìn)程:
[root@lnp ~]# ps -aux|grep redis root 7374 0.0 0.0 145312 7524 ? Ssl 16:37 0:00 redis-server 192.168.17.105:6379 root 10692 0.0 0.0 112724 984 pts/7 S+ 16:54 0:00 grep --color=auto redis
可以看到我們的redis-server的服務(wù)地址為192.168.17.105,端口為6379,對外訪問的時(shí)候需要指定對應(yīng)的IP和端口:
redis-cli -h 192.168.17.105 -p 6379
查找redis安裝目錄
> whereis redis redis: /usr/local/redis
我們可以看到redis在該目錄下安裝,然后找到配置文件redis.conf
> find /usr/local/redis/ -name redis.conf /usr/local/redis/etc/redis.conf
修改配置文件:
vim redis.conf
改該配置文件即可:
# requirepass foobared requirepass 123 指定密碼123
最后一步,重新加載配置文件即可:
redis-server /usr/local/redis/etc/redis.conf
二、連接測試
通過密碼-a訪問:
> redis-cli -h 192.168.17.105 -p 6379 -a 123
運(yùn)行結(jié)果:
[root@lnp etc]# redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused Could not connect to Redis at 127.0.0.1:6379: Connection refused not connected> exit [root@lnp etc]# redis-cli -h 192.168.17.105 -p 6379 192.168.17.105:6379> keys * (error) NOAUTH Authentication required. 192.168.17.105:6379> exit [root@lnp etc]# redis-cli -h 192.168.17.105 -p 6379 -a 123 Warning: Using a password with '-a' option on the command line interface may not be safe. 192.168.17.105:6379> keys * (empty list or set) 192.168.17.105:6379> exit
以上就是Linux下設(shè)置redis訪問密碼的方法的詳細(xì)內(nèi)容,更多請關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司其它相關(guān)文章!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
當(dāng)前題目:Linux中如何設(shè)置訪問redis-server的密碼?-創(chuàng)新互聯(lián)
分享網(wǎng)址:http://www.rwnh.cn/article10/cspddo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、軟件開發(fā)、網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè)、企業(yè)建站、全網(wǎng)營銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容