This article will guide you through several ways to check the Redis server version using the redis-cli
command-line interface. We'll cover different approaches and highlight where to find the version information within the output.
redis-cli
The simplest and most direct way to check the Redis version using redis-cli
is to use the INFO
command. This command provides a wealth of information about the Redis server, including the version number. Here's how:
redis-cli -h <hostname> -p <port>
where <hostname>
is the address of your Redis server (usually localhost
if it's running on the same machine) and <port>
is the port number Redis is listening on (usually 6379). If you're connecting to a local instance on the default port, you can simply use redis-cli
.INFO
command: Type INFO
and press Enter. This will return a large amount of server information.The version number will be located within this output, specifically in the redis_version
field. You might see something like this:
<code># Server redis_version:6.2.5 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:6e9037237a55b30f redis_mode:standalone os:Linux 5.15.0-76-generic x86_64 arch_bits:64 multiplexing_api:epoll atomicvar:atomic-builtin gcc_version:11.3.0 process_id:12345 run_id:a1b2c3d4e5f6 tcp_port:6379 uptime_in_seconds:3600 uptime_in_days:0 hz:10 configured_hz:10 lru_clock:2147483647 executable:redis-server config_file:/etc/redis/redis.conf</code>
In this example, the Redis version is 6.2.5
. You can easily parse this output to extract the version number using scripting languages like Python or shell scripting if needed.
This question is essentially the same as the first one. The INFO
command is the primary and most reliable method to determine the Redis server version via the command-line interface (redis-cli
). There are no other single commands that directly and concisely return only the version number.
Again, the INFO
command is the answer. While other commands might indirectly hint at the version (by the features they support or the way they format their output), INFO
is the dedicated command designed to provide comprehensive server information, including the version number.
The version number, as detailed above, is found within the output of the INFO
command. Specifically, it's in the redis_version
field. If you're working with the output programmatically, you can search for this field name to extract the version number efficiently. Remember that the exact formatting might vary slightly depending on the Redis version itself, but the redis_version
key will always be present.
The above is the detailed content of How to view versions using redis-cli. For more information, please follow other related articles on the PHP Chinese website!