How do I delete everything in Redis?

前端 未结 22 861
无人共我
无人共我 2020-11-28 17:18

I want to delete all keys. I want everything wiped out and give me a blank database.

Is there a way to do this in Redis client?

相关标签:
22条回答
  • 2020-11-28 17:29

    With redis-cli:

    • FLUSHDB – Deletes all keys from the connection's current database.
    • FLUSHALL – Deletes all keys from all databases.

    For example, in your shell:

    redis-cli flushall
    
    0 讨论(0)
  • 2020-11-28 17:30

    Answers so far are absolutely correct; they delete all keys.

    However, if you also want to delete all Lua scripts from the Redis instance, you should follow it by:

    SCRIPT FLUSH

    The OP asks two questions; this completes the second question (everything wiped).

    0 讨论(0)
  • 2020-11-28 17:30

    FLUSHALL Deletes all the Keys of All exisiting databases . FOr Redis version > 4.0 , FLUSHALL ASYNC is supported which runs in a background thread wjthout blocking the server https://redis.io/commands/flushall

    FLUSHDB - Deletes all the keys in the selected Database . https://redis.io/commands/flushdb

    The time complexity to perform the operations will be O(N) where N being the number of keys in the database.

    The Response from the redis will be a simple string "OK"

    0 讨论(0)
  • 2020-11-28 17:30
    1. Stop Redis instance.
    2. Delete RDB file.
    3. Start Redis instance.
    0 讨论(0)
  • 2020-11-28 17:30

    Its better if you can have RDM (Redis Desktop Manager). You can connect to your redis server by creating a new connection in RDM.

    Once its connected you can check the live data, also you can play around with any redis command.

    Opening a cli in RDM.

    1) Right click on the connection you will see a console option, just click on it a new console window will open at the bottom of RDM.

    Coming back to your question FLUSHALL is the command, you can simply type FLUSHALL in the redis cli.

    Moreover if you want to know about any redis command and its proper usage, go to link below. https://redis.io/commands.

    0 讨论(0)
  • 2020-11-28 17:32

    i think sometimes stop the redis-server and delete rdb,aof files。 make sure there’s no data can be reloading. then start the redis-server,now it's new and empty.

    0 讨论(0)
提交回复
热议问题