How to empty a redis database? How to empty a redis database? database database

How to empty a redis database?


You have two options:

  • FLUSHDB - clears currently active database
  • FLUSHALL - clears all the existing databases


Be careful here.

FlushDB deletes all keys in the current database while FlushALL deletes all keys in all databases on the current host.


tldr: flushdb clears one database and flushall clears all databases

Clear CURRENT

Delete default or currently selected database (usually `0) with

redis-cli flushdb

Clear SPECIFIC

Delete specific redis database with (e.g. 8 as my target database):

redis-cli -n 8 flushdb 

Clear ALL

Delete all redis databases with

redis-cli flushall