search

Home  >  Q&A  >  body text

How to import dumb.rdb file on redis and export to mysql database

<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粉555696738P粉555696738507 days ago719

reply all(2)I'll reply

  • P粉178132828

    P粉1781328282023-08-26 10:52:12

    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.

    reply
    0
  • P粉817354783

    P粉8173547832023-08-26 10:04:03

    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 +';');

    reply
    0
  • Cancelreply