Reputation: 17072
I've been playing with redis (and add some fun with it) during the last fews days and I'd like to know if there is a way to empty the db (remove the sets, the existing key....) easily.
During my tests, I created several sets with a lot of members, even created sets that I do not remember the name (how can I list those guys though ?).
Any idea about how to get rid of all of them ?
Upvotes: 213
Views: 172337
Reputation: 500
With redis-cli:
FLUSHDB [ASYNC | SYNC]
ASYNC: flushes the database asynchronously
SYNC: flushes the database synchronously
Note: an asynchronous FLUSHDB command only deletes keys that were present at the time the command was invoked. Keys created during an asynchronous flush will be unaffected.
Upvotes: 1
Reputation: 11831
Be careful here.
FLUSHDB
deletes all keys just in the current database (0 by default), while FLUSHALL
deletes all keys in all databases (on the current host).
Upvotes: 155
Reputation: 5508
tldr: flushdb
clears one database and flushall
clears all databases
Delete default or currently selected database (usually 0
) with
redis-cli flushdb
Delete specific redis database with (e.g. 8
as my target database):
redis-cli -n 8 flushdb
Delete all redis databases with
redis-cli flushall
Upvotes: 75
Reputation: 1478
There are right answers but I just want to add one more option (requires downtime):
Upvotes: 5
Reputation: 1161
open your Redis cli and There two possible option that you could use:
FLUSHDB - Delete all the keys of the currently selected DB. FLUSHALL - Delete all the keys of all the existing databases, not just the currently selected one.
Upvotes: 0