I think one of the easiest ways is to export the MySQL database to JSON, and then use mongorestore to import it into the MongoDB database.
Step 1: Export MySQL Database to JSON
Upload mysql dump file to MySQL database if necessary
Open MySQL Workbench and connect to MySQL database
Go to Schema Viewer> Select Database> Tables> right-click the table name to export
Select "Export Tabular Data Wizard"
Set the file format to .json and enter a file name, for example tablename.json.
Note. All tables must be exported separately.
Step 2: Import the JSON files into MongoDB using the mongorestore command
The mongorestore command should be run from the server command line (not the mongo shell)
Note that you may need to provide authentication information, as well as the --jsonArray parameter, see the mongorestore documentation for more information.
mongoimport -d dbname -u ${MONGO_USERNAME} -p ${MONGO_PASSWORD} --authenticationDatabase admin -c collectionname --jsonArray --file tablename.json
Note. This method will not work if the source MySQL database contains BLOB / binary data.
pengz May 24 '19 at 17:24 2019-05-24 17:24
source share