Last Updated: February 25, 2016
·
43.97K
· raphaelstolt

List all databases in a Redis instance

To list all databases of a Redis instance (i.e. version 2.2) the following command yields the desired information.

$ redis-cli INFO | grep db
db0:keys=1500,expires=2
db1:keys=200000,expires=5
db2:keys=350003,expires=15

If you're just interested in the amount of currently existing databases (which is limited to 16 per default but can be increased by altering redis.conf) pipe it further to word count.

$ redis-cli INFO | grep db | wc -l
3

Inside a redis-cli instance you can also issue the INFO command with the optional keyspace parameter.

redis> INFO keyspace
# Keyspace
db0:keys=8577,expires=0

In newer versions (i.e. 2.6.2) you can even just call redis-cli INFO KEYSPACE on the console which gives you also the desired information.