6

I had redis installed without password. Then I tried to put password without success and decided to delete all related to redis from my server. After that, I've installed redis once again and set a password successfully. The problem is that now is creating a new database and not reading from the old one. I am running the same command from sabe directory. $~/ redis-server

I've also tried to check if is generating a new dump.rdb file with:

find / -type f -name "*.rdb"

But is only finding my correct dump.rdb file that I'd like to use.

Is there a way to import my last database to this new one? Or, Is there a way to start my server using the correct dump.rdb file?

mscdex
  • 104,356
  • 15
  • 192
  • 153
Rodrigo Pereira
  • 1,834
  • 2
  • 17
  • 35
  • How did you delete previous data ? Did you `FLUSHALL` ? – Niloct Jan 11 '15 at 15:19
  • No, I've opened the file to check and is everything there.. – Rodrigo Pereira Jan 11 '15 at 15:40
  • Make sure that your .conf's `dir` directive is set to the directory where your RDB file is. Furthermore, verify that the filename matches to the value in `dbfilename`. If these are set correctly and still no luck - what does the log say? – Itamar Haber Jan 11 '15 at 16:03
  • possible duplicate of [How do I move a redis database from one server to another?](http://stackoverflow.com/questions/6004915/how-do-i-move-a-redis-database-from-one-server-to-another) – Ofir Luzon Jan 11 '15 at 16:36

2 Answers2

6

Copy your rdb file to correct path:

sudo cp /path/to/rdb/dump.rdb /var/lib/redis/dump.rdb

Make redis owner of new rdb file:

sudo chown redis: /var/lib/redis/dump.rdb

Open redis config file in /etc/redis/redis.conf.

Make sure these two lines are existed and not commented:

dbfilename dump.rdb
dir /var/lib/redis

Turn off other persistence method by changing appendonly option to no (because redis will consider that method first):

appendonly yes

Save and close the config file and restart redis-server:

systemctl restart redis-server

This will work if redis-server is compatible with your rb file.

6

The Simplest way to go is

redis-server --dbfilename dump.rdb --dir /home/in_which_directory_rdb_file_exists

Change the .rdb file name and the directory name as per your requirements.

Amin Pial
  • 383
  • 6
  • 12