PASSWORD RESET

Your destination for complete Tech news

How to empty a Redis database?

593 0
< 1 min read

To empty a specific Redis database, you can use the “FLUSHDB” command. This command removes all the keys from the current database.

You can run the command in the redis-cli by typing:

$ redis-cli FLUSHDB

You can also use the python redis library to empty a specific Redis database:

import redis
r = redis.Redis()
r.flushdb()

It’s important to note that before using the FLUSHDB command you have to select the database you want to empty using the SELECT command, for example:

$ redis-cli SELECT 0
$ redis-cli FLUSHDB

This command first selects the database 0 and then empties it.

Please be careful when using this command, as it will permanently delete all data stored in the current selected database.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.