MongoDb: How to import dump data from .gz file?

Dump command: mongodump –host localhost:27017 –gzip –db Alex –out ./testSO Restore Command: mongorestore –host localhost:27017 –gzip –db Alex ./testSO/Alex Works perfectly! While using archive: Dump command: mongodump –host localhost:27017 –archive=dump.gz –gzip –db Alex Restore Command: mongorestore –host localhost:27017 –gzip –archive=dump.gz –db Alex Note:- While using archive you need to stick with the database name. Different … Read more

How to use the dumped data by mongodump?

You need to use mongorestore, not mongoimport … which is used for things like importing json, or csv, etc. From the back-up-with-mongodump docs: mongodump reads data from a MongoDB database and creates high fidelity BSON files which the mongorestore tool can use to populate a MongoDB database. mongodump and mongorestore are simple and efficient tools … Read more

How to use mongodump for 1 collection

I think it’s just: mongodump –db=<old_db_name> –collection=<collection_name> –out=data/ mongorestore –db=<new_db_name> –collection=<collection_name> data/<db_name>/<collection_name>.bson Also see docs here and here. Btw, the other way to move the collection from one database to another is to use renameCollection: db.runCommand({renameCollection:”<old_db_name>.<collection_name>”,to:”<new_db_name>.<collection_name>”}) Here’s some related SO threads: How to copy a collection from one database to another in MongoDB How to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)