安装redis-dump
[sudo] npm install redis-dump -g
导出数据
$ redis-dump --help Usage: redis-dump [OPTIONS] -h <hostname> Server hostname (default: 127.0.0.1) -p <port> Server port (default: 6379) -a <auth> Server auth password (default: '') -d <db> Database to be selected (default: 0) -f <filter> Query filter (default: *) --convert Convert from json to redis commands --help Output this help and exit --json Output result as json --pretty Make pretty indented output (use with --json) Examples: redis-dump redis-dump -p 6500 redis-dump -p 6500 -a password redis-dump -f 'mydb:*' > mydb.dump.txt redis-dump --json > mydb.json The output is a valid list of redis commands. That means the following will work: redis-dump > dump.txt # Dump redis database cat dump.txt | redis-cli # Import redis database from generated file
导入数据(linux下)
cat db.txt | redis-cli -n 0
window下,找到redis目录,
cat db.txt | ./redis-cli.exe -n 0
来自:https://www.npmjs.com/package/redis-dump