How to connect to Redis using the command line in Linux?
To connect to Redis using the command line in Linux, follow these steps:
- Open the terminal.
- Enter the following command to install the Redis client:
sudo apt-get install redis-cli
- 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,
- Enter the password (if the Redis server requires a password for connection).
- 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.
- GIVE UP
QUIT
This way, you can use the command line to connect to Redis and perform the necessary operations.