redis-cli(1)
Command-line interface for interacting with Redis servers and executing Redis commands.
Synopsis
redis-cli [OPTIONS] [COMMAND] [ARG] [ARG] ...Description
redis-cli is the official command-line client for Redis, allowing you to send commands to a Redis server and read responses. It supports interactive mode for an interactive shell, or single-command mode for executing one command and exiting. It can connect to local or remote Redis instances and supports authentication, pipelining, and scripting.
Common use cases include data inspection, database administration, performance monitoring, and testing Redis functionality. redis-cli also provides helpful features like command history, auto-completion, and special commands for cluster management and debugging.
Common options
| Flag | What it does |
|---|---|
-h <hostname> | Server hostname or IP address (default: 127.0.0.1) |
-p <port> | Server port number (default: 6379) |
-a <password> | Password to authenticate with the Redis server |
-u <uri> | Redis URI (e.g., redis://user:password@host:port/db) |
-n <db> | Select database number (default: 0) |
-i <interval> | Execute command every N seconds (continuous monitoring mode) |
--raw | Output raw replies without formatting or colors |
--csv | Output results in CSV format |
-x | Read the last argument from standard input |
--pipe | Transfer raw Redis protocol data from stdin; mass insert mode |
--scan | Scan keys matching a pattern (iterates through keys efficiently) |
--eval <script> | Execute a Lua script with optional arguments |
Examples
Test connectivity to the default Redis server (localhost:6379)
redis-cli pingConnect to a remote Redis server with authentication and retrieve a key value
redis-cli -h redis.example.com -p 6380 -a mypassword GET mykeySelect database 1 and set a key-value pair
redis-cli -n 1 SET counter 100Delete all keys in the current database (interactive confirmation mode)
redis-cli FLUSHDBScan for all keys matching the pattern 'user:*' and show first 20 results
redis-cli --scan --pattern 'user:*' | head -20Monitor server statistics, refreshing every second
redis-cli -i 1 INFO statsBulk insert Redis commands from a file using pipeline mode
cat commands.txt | redis-cli --pipeExecute a Lua script that returns a key and an argument
redis-cli EVAL "return {KEYS[1],ARGV[1]}" 1 mykey myarg