How to connect to Redis using the command line in Linux?

To connect to Redis using the command line in Linux, follow these steps:

  1. Open the terminal.
  2. Enter the following command to install the Redis client:
sudo apt-get install redis-cli
  1. After the installation is complete, you can connect to the Redis server using the following command:
redis-cli -h <hostname> -p <port>

In this case, refers to the host name or IP address of the Redis server, and refers to the port number of the Redis server (default is 6379).

  1. Enter the password (if the Redis server requires a password for connection).
  2. Once connected, you can interact with the server using Redis commands, such as:
SET key value
GET key

The SET command is used to assign key-value pairs, and the GET command is used to retrieve the value of a key.

  1. GIVE UP
QUIT

This way, you can use the command line to connect to Redis and perform the necessary operations.

广告
Closing in 10 seconds
bannerAds