How to import from sql dump to MongoDB?

I am trying to import data from a MySQLdump file .sqlfor import into MongoDB. But I have not seen any mechanism for an RDBMS to migrate NoSQL data.
I tried converting the data to JSON and CSV, but it does not give m the desired output in MongoDB.
I decided to try Apache Sqoop, but mostly for SQL or NoSQL for Hadoop.
I could not understand how to transfer data from "MySQL" to "MongoDB"?
I was thinking somewhere, besides what I tried so far?
Hoping to hear the best and fastest solution for this type of migration.

+7
source share
3 answers

I suggest you dump the Mysql data into a CSV file, you can also try a different file format, but make sure the file format is friendly, so you can easily import the data into MongoDB, supporting MongoDB and Mysql CSV file format very well.

You can try using mysqldump or OUTFILE to dump Mysql databases for backup, using mysqldump may take a lot of time, so take a look at How can I optimize mysqldump for a large database? .

Then use the mongoimport tool to import the data.

As far as I know, there are three ways to optimize imports:

  • mongoimport --numInsertionWorkers N , N .

  • mongod --njournal , .

  • .

, , , , , , , , MongoDB, .

, .

, .

+4

Mongify, / SQL MongoDB. MySQL, PostgreSQL, SQLite, Oracle, SQLServer DB2.

ruby rubygems . , mongify.

+1

, - MySQL JSON, mongorestore MongoDB.

1: MySQL JSON

mysql MySQL,

MySQL Workbench MySQL

> > >

" "

.json , tablename.json.

. .

2: JSON MongoDB mongorestore

mongorestore ( mongo)

, , --jsonArray, . mongorestore .

mongoimport -d dbname -u ${MONGO_USERNAME} -p ${MONGO_PASSWORD} --authenticationDatabase admin -c collectionname --jsonArray --file tablename.json
0

Source: https://habr.com/ru/post/1669109/


All Articles