/mysql-mongo-mapper

Mysql database to mongo schema mapper

Primary LanguageTypeScriptMIT LicenseMIT

MySQL to MongoDB data migration tool

A Node.js script to migrate MySQL data to MongoDB, mapping MySQL tables to MongoDB collections.

Will allow migrations from and to remote sites.

mysql-to-mongo

Migrate your existing MySQL data into MongoDB

Open terminal in your working directory and .....

Method I

  1. Clone project

    git clone https://github.com/dannysofftie/mysql-mongo-migrate.git

  2. Install dependencies

    npm install

  3. Make it happen 😉

    npm run migrate

Method II

  1. Install package globally

    npm i -g mysql-mongo-migrate

  2. Run command

    $> mysql-mongo-migrate


Issues might occur if you don't have authentication set up in your MongoDB database, as read and write roles are required when inserting bulk data into MongoDB.

Follow below steps to enable authentication in your server:

This set up is for Linux distros only. Check online for your operating system if not a linux distro.

  • Uncomment the following code block at the bottom of /etc/mongo.conf

    $> sudo vi /etc/mongo.conf
    
       # security:
       #      authorization: enabled
  • Login to your server and create a user for your database.

    $>  mongo
    >   use databaseName
    >   db.createUser({user: "username", pwd: "password", role: [{roles: "readWrite", db: "databaseName"}]})
    

    Replace with your preferred credentials. You will use them to do migration in the other steps

  • Exit the mongo shell and restart mongod service.

    $>  sudo service restart mongo

    You should be ready to migrate your data now.

Roadmap

  • Retrieve MySQL database models and data
  • Generate Mongoose schemas in Typescript
  • Dump MySQL data into MongoDB