redis备忘录
前言
记录一些学习 Redis 过程中遇到的问题
指令
-
选择数据库
select [数据库序号]
e.g.
select 0
-
显示所有的key
keys *
-
显示某一个 list 的所有内容
lrange key 0 -1
-
删除所有数据库
flushall
-
删除当前数据库
flushdb
-
帮助
help
To get help about Redis commands type:
"help @<group>" to get a list of commands in <group>
"help <command>" for help on <command>
"help <tab>" to get a list of possible help topics
"quit" to exit
debian11 安装redis
# 安装
sudo apt update
sudo apt install redis-server
# 查看版本
redis-server --version
# Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=6d95e1af3a2c082a
# 检查服务状态
sudo systemctl status redis-server
# 检查默认端口号
netstat -ant |grep 6379
# 配置文件目录
# /etc/redis/redis.conf
关于配置文件
# 允许外部访问,需要把下面这行注释掉
# bind 127.0.0.1 ::1
# 允许外网访问,将这行配置改为no,否则Another Redis Disktop Manager 从服务器外部访问会报错:
# Client On Error: Error: write ECONNRESET Config right?
# protected-mode yes
protected-mode no
# 其它配置,根据需求修改
配置修改后,执行 sudo systemctl restart redis-server
重启redis-server
参考:Redis Client On Error Error write ECONNABORTED Config right