npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mysql-mongo-etl

v1.4.0

Published

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

Downloads

4

Readme

MySQL to MongoDB data migration tool

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

Supports migrations over network, use cases:

  1. MySQL database hosted in GCP, to MongoDB hosted in Digital Ocean,
  2. MySQL local database, to MongoDB Atlas,
  3. MySQL database hosted in Linode, to local MongoDB instance,
  4. And so much more ...

Will allow migrations from and to remote sites.

mysql-mongo-etl

Migrate your existing MySQL data into MongoDB

Open terminal/command promt and follow any of below methods.

Before you continue, ensure you have Node.js installed in your system. See here for more instructions. If you have it installed, you can continue below.

Method I (For developers)

  1. Clone project

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

  2. Change working directory

    cd mysql-mongo-etl

  3. Install dependencies

    npm install

  4. Make it happen :wink:

    npm run migrate

Method II (This is for non-developers/non technical guys)

  1. Install package globally

    npm install -g mysql-mongo-etl

  2. Run command

    mysql-mongo-etl


For both methods, you will be prompted to enter authentication credentials for your MySQL and MongoDB databases. Ensure you have access credentials that have read/write roles enabled, or else you will encounter errors.


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.

  • Login to your server and create a user for your database.

    $ mongo

     mongo~$ use databaseName
     mongo~$ 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.

  • Uncomment the following code block at the bottom of /etc/mongo.conf, or add if not available.

    sudo vi /etc/mongo.conf

       # security:
       #      authorization: enabled
  • After enabling authentication and create a user with appropriate credentials, restart your mongo instance for this to take effect

    sudo service restart mongo


You should be ready to migrate your data now. Follow Method I or Method II as above.


Roadmap

  • [x] Retrieve MySQL database models and data
  • [x] Generate Mongoose schemas in Typescript
  • [x] Dump MySQL data to MongoDB
  • [x] Support migrations over the network
  • [ ] Prevent duplicates in subsequent migrations

LICENSE

MIT License

Copyright (c) 2018 - 2020 Danny Sofftie

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.