How to import dumb.rdb file on redis and export to mysql database
P粉555696738
P粉555696738 2023-08-25 11:36:38
0
2
669
<p>RDB files of REDIS servers imported from other servers. I have installed REDIS on my local machine and am trying to import it to my local REDIS server. Mainly I want to store all REDIS data in mysql database. Is there any direct procedure to import DUMB.RBD file into mysql database. Is there any other process to import REDIS data into CSV format. Any help would be very helpful to me. </p>
P粉555696738
P粉555696738

reply all(2)
P粉178132828

Redis is a schema-less key-value NOSQL database. There aren't any built-in solutions for moving data from Redis to a SQL database or CSV file. But you can write some code yourself to do this:

  1. Use SCAN to get all keys in the Redis instance.
  2. Getting their values ​​depends on the key type (can be determined by TYPE).
  3. Write SQL.
P粉817354783

Get answers with Node js and Redis.

For the import, I used the following command after shutting down the redis server

sudo cp /var/dump.rdb /home/etc/redis/dump.rdb

Use Nodejs to parse Redis data and connect to mysql at the same time.

var mysql      = require('mysql');
var connection = mysql.createConnection({
host              : 'localhost',
port              : '3306',
database          : 'db',
user              : 'root',
password          : 'password',
insecureAuth      : true,
multipleStatements: true
});
var post  = {name: practice.name, practiceId: practice.id,type: practice.wid};
var query = connection.query('INSERT INTO  facilities SET ?', post, function(err, result) { });

                console.log(query.sql +';');
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template