导读:
Redis是一种高性能的键值对数据库,它支持多种数据结构和丰富的操作命令 。在使用Redis时,有时需要查看当前数据库的名字,本文将介绍如何通过命令行或者编程语言来查看Redis数据库的名字 。
1. 命令行方式
可以通过redis-cli命令连接到Redis服务器 , 并执行INFO命令来查看当前数据库的名字 。
步骤:
1)打开终端,输入redis-cli命令连接到Redis服务器;
2)输入INFO命令,查看输出结果中的db0字段 , 即为当前数据库的名字 。
示例代码:
$ redis-cli
127.0.0.1:6379> INFO
# Server
redis_version:5.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:8c4b7e2d5d6bc5a6
redis_mode:standalone
os:Linux 4.15.0-45-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:7.4.0
process_id:1310
run_id:7a3aa3f2f2d8e8d4b8afba2f80b09c2b5f4cc6d2
tcp_port:6379
uptime_in_seconds:374
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:13035334
executable:/usr/local/bin/redis-server
config_file:
# Clients
connected_clients:1
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0
# Memory
used_memory:1010464
used_memory_human:987.47K
used_memory_rss:3735552
used_memory_rss_human:3.56M
used_memory_peak:1010464
used_memory_peak_human:987.47K
used_memory_peak_perc:100.00%
used_memory_overhead:986736
used_memory_startup:791824
used_memory_dataset:236728
used_memory_dataset_perc:23.40%
allocator_allocated:1262384
allocator_active:1572864
allocator_resident:3145728
total_system_memory:8252686848
total_system_memory_human:7.68G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.24
allocator_frag_bytes:310480
allocator_rss_ratio:2.00
allocator_rss_bytes:1572864
rss_overhead_ratio:1.19
rss_overhead_bytes:-4194304
mem_fragmentation_ratio:3.70
mem_fragmentation_bytes:2678512
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:0
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1581479733
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0
# Stats
total_connections_received:2
total_commands_processed:1
instantaneous_ops_per_sec:0
total_net_input_bytes:31
total_net_output_bytes:0
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
# Replication
role:master
connected_slaves:0
master_replid:3c5f7d4b8e9d4c5f1be6c1dd50c8a1f5d29f9d5c
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:0.142155
used_cpu_user:0.113174
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=1,expires=0,avg_ttl=0
2. 编程语言方式
可以通过编程语言中的Redis客户端库来连接到Redis服务器,并执行相应的命令来查看当前数据库的名字 。
【redis数据库名称 redis查看数据库名字】1)选择合
推荐阅读
- redis哪个版本稳定 Redis版本之间兼容吗
- 如何评价战意服务器? 战意服务器怎么看
- 如何在马来西亚服务器上畅玩游戏? 马来西亚服务器怎么玩
- MYSQL数据库介绍 mysql数据库 vip
- mysql一次修改多条数据 mysql大批量修改