Stefan Xenopol
1 year
Claus-Theodor Riegg
8 years
Andreas Vöst
1 year
Andreas Vöst
1 year

Delete specific Redis-DBs

Posted . Visible to the public.

To delete a specific redis-DB you need to use the FLUSHDB-command in combination with the SELECT-command. For more information have a look at the documentation for FLUSHDB Show snapshot and SELECT Show snapshot .


By default when connecting to a redis-instance you always connect with db0.

When connecting to the db you can list your keyspaces/databases with:

# Show info about all databases> INFO keyspace
# Keyspace

In this example you can see that we have 3 DBs.

If you are unsure which DB you want to remove have a look at the keys in the databases by selecting the database and then listing all keys.

# Select db1> SELECT 1

# List all keys[1]> KEYS *
[possibly long output or "empty list or set"]

In order to delete the keys you need to select the DB first and then remove all keys using FLUSHDB


If you are using a redis cluster this will delete the database across all nodes in your cluster.

# Select db1> SELECT 1

# If possible, check if keys can be really deleted[1]> KEYS *

# Remove all keys[1]> FLUSHDB

# Double check if all keys are gone[1]> KEYS *
(empty list or set)
Stefan Xenopol
Last edit
Deleted user #4941
Source code in this card is licensed under the MIT License.