Last Updated: December 27, 2020
·
18.65K
· abh1nv

Delete keys in Redis

Note: Exercise caution when using any of these.

Delete all keys in the selected database:

1) The easy way

redis-cli -n <database number> flushdb

2) The fun way

redis-cli keys ‘*’ | awk ‘{print $1}’ | xargs redis-cli DEL

Delete all keys in all databases:

redis-cli flushall

2 Responses
Add your response

Or you could run the more simple redis-cli flushall; though it responds even with OK when no keys were flushed. Attention: never run this on a productive system.

over 1 year ago ·

Aha! I had no idea flushall and flushdb existed. Thank you for that. I've updated the tip :)

over 1 year ago ·