[Getting started with Redis] (1) Install and configure Redis

[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.servicebe used to check the status of Redis:
insert image description here

3. Configure Redis

Edit the Redis configuration file:sudo vim /etc/redis/redis.conf

  1. Set Redis password:
requirepass 密码
  1. Allow remote access: Comment out the line bind
# bind 127.0.0.1 ::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

  1. Log in locally:
redis-cli
auth 密码
  1. Standard login method:
redis-cli -h x.x.x.x -p 6379 -a 密码

Guess you like

Origin blog.csdn.net/qq_40039731/article/details/124738751