Guide to Flush Redis Databases and Keys

Category : Redis

Using Redis was persistent databases? Want to delete keys of a particular database or delete all the databases from your Redis server?

Redis has grown to become one of the most popular NoSQL database systems (not to mention cache systems) in use today. Perhaps the biggest advantage Redis has over other NoSQL systems is that runs almost entirely in memory.

In Redis Official Documentation deleting refers to flushing. Flushing means removing or deleting any data. There are two types of flushing methods.

  • FLUSHDB – Flushes/Deletes a Single Database Keys
  • FLUSHALL – Flushes/Deletes all the databases on Redis Server

We will tell you commands for both the flushing methods. Kindly proceed the following guide

Deleting all keys from current selected Database

redis-cli FLUSHDB

Deleting all keys from a specific Database

redis-cli -n 5 FLUSHDB
Here ‘5’  is the database number you want to delete/flush

Deleting all the databases from Redis Server

redis-cli FLUSHALL

For more commands related to Redis, read here: https://www.basezap.com/learn-basic-redis-commands/