Simple operation of linux redis
1. Install redis on centOS system https://blog.csdn.net/weixin_42835409/article/details/119562074
2. After the installation is complete, enter redis-cli in the terminal and report redis-cli -bash: redis-cli: command not found Problem Solving
Enter Go to the src/bin directory under the redis file and copy redis-cli to the /usr/local/bin/ directory, so that the redis-cli command can be used directly in any directory
cp redis-cli /usr/local/bin/
3. Connect to local redis
#默认端口 6379 即 127.0.0.1:6379
redis-cli
4. Connect to remote
# -h 地址 -p 端口
redis-cli -h 10.47.9.3 -p 16362
5. If redis has a password, log in and enter the password
# auth 空格+密码(123456 为密码)
auth 123456
6. Set password
# pass_密码
config set requirepass pass_123456
7. Obtain password
config get requirepass
8. Switch db library
select 库编号
# 如 切换至db2 => select 2
9. View all keys
keys *
# 1) "key1"
10. Hash type data Redis Hash type data common command summary
# 所有查看数据
hgetall <key>
# 查看某个key的数据 返回hash表中指定key的field的值
hget <key> <field>
# 存入或修改数据
hset <key> <field> <value>
11. String type data
# 查看数据
get <key>
# 存入或修改数据
set <key> <value>
12. View a key data storage type
type <key>
13. Delete data
Delete key
del <key>
delete field
hdel <key> field
14. Redis startup
Enter the redis/bin directory to execute the startup command, where redis.conf needs to write the actual location, and execute the following command when it is in the redis-server directory
./redis-server redis.conf
Check whether the startup is successful
ps -ef | grep redis
Redis.conf configuration details https://blog.csdn.net/sinat_25207295/article/details/117925174
15. Other operation references —> ... Redis knowledge you need to master... , Redis common command manual