4

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?

4

2 回答 2

5

停止redis-server

sudo service redis-server stop

将您的 rdb 文件复制到正确的路径:

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

使 redis 成为新 rdb 文件的所有者:

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

中打开 redis 配置文件/etc/redis/redis.conf

确保这两行存在且未注释:

dbfilename dump.rdb
dir /var/lib/redis

appendonly通过将选项更改为关闭其他持久性方法no(因为redis将首先考虑该方法):

appendonly yes

保存并关闭配置文件并启动redis-server

sudo service redis-server start

redis-server如果与您的rb文件兼容,这将起作用。

于 2018-02-10T10:28:03.373 回答
0

简单的方法是

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

根据您的要求更改.rdb file namedirectory名称。

于 2022-02-27T06:17:58.907 回答