[Getting started with Redis] (1) Install and configure Redis
This article is based on Ubuntu 20.04 LTS and Redis 5.0.7.
1. Install Redis
sudo apt update
sudo apt install redis-server
2. Check Redis status
After Redis installation is complete, it will start automatically, which can systemctl status redis-server.service
be used to check the status of Redis:
3. Configure Redis
Edit the Redis configuration file:sudo vim /etc/redis/redis.conf
- Set Redis password:
requirepass 密码
- Allow remote access: Comment out the line bind
# bind 127.0.0.1 ::1
- Modify port (default 6379, can not be modified)
port 6379
4. Restart Redis
sudo systemctl restart redis-server.service
5. Login to Redis
- Log in locally:
redis-cli
auth 密码
- Standard login method:
redis-cli -h x.x.x.x -p 6379 -a 密码