如何列出所有Redis数据库? [英] How to List All Redis Databases?

查看:199
本文介绍了如何列出所有Redis数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行这个命令来访问我的 redis 服务器.

I ran this command to access my redis server.

telnet 127.0.0.1 6379

显示我所有数据库的命令是什么?

What is the command to show all of my databases?

推荐答案

没有命令可以执行此操作(例如您会使用 MySQL 执行此操作).Redis 数据库的数量是固定的,在配置文件中设置.默认情况下,您有 16 个数据库.每个数据库都由一个数字(不是名称)标识.

There is no command to do it (like you would do it with MySQL for instance). The number of Redis databases is fixed, and set in the configuration file. By default, you have 16 databases. Each database is identified by a number (not a name).

可以使用下面的命令来知道数据库的数量:

You can use the following command to know the number of databases:

CONFIG GET databases
1) "databases"
2) "16"

您可以使用以下命令列出定义了某些键的数据库:

You can use the following command to list the databases for which some keys are defined:

INFO keyspace
# Keyspace
db0:keys=10,expires=0
db1:keys=1,expires=0
db3:keys=1,expires=0

请注意,您应该使用redis-cli"客户端来运行这些命令,而不是 telnet.如果你想使用telnet,那么你需要运行这些使用Redis协议格式化的命令.

Please note that you are supposed to use the "redis-cli" client to run these commands, not telnet. If you want to use telnet, then you need to run these commands formatted using the Redis protocol.

例如:

*2
$4
INFO
$8
keyspace

$79
# Keyspace
db0:keys=10,expires=0
db1:keys=1,expires=0
db3:keys=1,expires=0

您可以在此处找到 Redis 协议的描述:http://redis.io/topics/protocol

You can find the description of the Redis protocol here: http://redis.io/topics/protocol

这篇关于如何列出所有Redis数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆