Database / REDIS
How do you connect to Redis using the CLI?
redis-cli is Redis's interactive command-line client, and connecting to a running instance is typically a single command specifying the host, port, and (if configured) authentication credentials:
redis-cli -h localhost -p 6379 redis-cli -h redis.example.com -p 6379 -a mypassword redis-cli -h localhost -p 6379 --tls # for a TLS-enabled instance
Once connected, commands can be typed interactively, or the CLI can run a single command non-interactively and exit (redis-cli GET mykey), which is convenient for scripting. Passing a password with -a on the command line is convenient but leaves the credential visible in shell history and process listings; --user combined with -a supports ACL-based authentication for a specific user rather than the legacy single-password AUTH, and reading the password from an environment variable or a config file is generally the safer approach for anything beyond quick local testing.
More Related questions...
