一绍弟、安裝redis
1技即、安裝redis數(shù)據(jù)庫
yum install redis
2、下載fedora的epel倉庫
yum install epel-release
3樟遣、安裝完畢后而叼,使用下面的命令啟動(dòng)redis服務(wù)
# 啟動(dòng)redis
systemctl start redis service
# 停止redis
systemctl stop redis service
# 查看redis運(yùn)行狀態(tài)
service redis status
# 查看redis進(jìn)程
ps -ef | grep redis
4身笤、設(shè)置redis為開機(jī)自動(dòng)啟動(dòng)
systemctl enable redis.service
5、取消redis為開機(jī)自動(dòng)啟動(dòng)
systemctl disable redis.service
6葵陵、進(jìn)入redis服務(wù)
# 進(jìn)入本機(jī)redis
redis-cli
# 列出所有key
keys *
#添加數(shù)據(jù)
set key 111
#取出數(shù)據(jù)
get key
二液荸、修改redis默認(rèn)端口和密碼
1、打開配置文件
vi /etc/redis.conf
2埃难、修改默認(rèn)端口莹弊,查找 port 6379 修改為相應(yīng)端口即可
3、修改默認(rèn)密碼涡尘,查找 requirepass foobared 將 foobared 修改為你的密碼
三忍弛、使用redis desktop manager遠(yuǎn)程連接redis
1、安裝后啟動(dòng)考抄,新建一個(gè)連接
2细疚、填寫如下信息后點(diǎn)擊“Test Connection”測(cè)試是否連接成功
3、如果長(zhǎng)時(shí)間連接不上川梅,可能有兩種可能性
a)bind了127.0.01:只允許在本機(jī)連接redis
b)protected-mode設(shè)置了yes(使用redis desktop manager工具需要配置疯兼,其余不用)
解決辦法:
# 打開redis配置文件
vi /etc/redis.conf
# 找到 bind 127.0.0.1 將其注釋
# 找到 protected-mode yes 將其改為
protected-mode no
4、重啟redis,再次連接