mongorestore

Mongoimport ignore leading zero in csv

假装没事ソ 提交于 2021-02-17 05:13:20
问题 I have a .CSV export file from a SQL Server database, with a phone number field (number type) that field values started with leading zero. Leading zero is presented in the CSV file. When I attempt to mongoimport it to DB (in string type) I find data imported without leading zero. The target field number is string. How can I solve this problem? 回答1: you can specifically define the type of the field using the import option --columnsHaveTypes Instructs mongoimport that the field list specified

Mongoimport ignore leading zero in csv

我们两清 提交于 2021-02-17 05:13:19
问题 I have a .CSV export file from a SQL Server database, with a phone number field (number type) that field values started with leading zero. Leading zero is presented in the CSV file. When I attempt to mongoimport it to DB (in string type) I find data imported without leading zero. The target field number is string. How can I solve this problem? 回答1: you can specifically define the type of the field using the import option --columnsHaveTypes Instructs mongoimport that the field list specified

Restoring the database dump of an older version of mongo to a new version of mongo

元气小坏坏 提交于 2020-06-09 18:12:16
问题 Currently, I have an older version of mongo, i.e 2.6 running on my system. I already have my site in production and have a lot of client data. I am planning an upgrade to mongo 3.2. So, my question is whether mongorestore of mongo v3.2 work with data dump of v2.6 ? Or, is it known to create problems? Any answers will be invaluable! Thanks 回答1: I asked this same question on the official MongoDB mailing list. They said not to upgrade more than 1 major version at a time. (Major versions being: 2

Mongorestore in a Dockerfile

我的未来我决定 提交于 2020-01-22 13:25:47
问题 I want to create a Docker image that starts a mongo server and automatically restores from a previous mongodump on startup. Here is my Dockerfile for the image: FROM mongo COPY dump /home/dump CMD mongorestore /home/dump When I run this, I run into this error: Failed: error connecting to db server: no reachable servers Is there any way to get the mongorestore command to run through Docker? 回答1: With help from this answer, Marc Young's answer, and the Dockerfile reference I was able to get

mongorestore failed: restore error: error applying oplog: applyOps: EOF

霸气de小男生 提交于 2020-01-16 01:47:08
问题 I created mongodb dump with next command: mongodump /host:%MONGODB_HOST% /authenticationDatabase:admin /username:username /password:password /oplog After that I'm trying to restore dump with a command: mongorestore /noIndexRestore /oplogReplay /numParallelCollections:1 dump It restores all db and fails to replay oplog: Failed: restore error: error applying oplog: applyOps: EOF local mongoDB version: 3.0.2 (Windows 7) remote mongoDB version: 2.6.7 (Windows 8) 回答1: This is a bug with the Go

MongoDB mongorestore and existing collection with records

左心房为你撑大大i 提交于 2019-12-29 11:41:10
问题 I need to import (restore) a collection generated with mongodump into an existing database and I'd like the records to be merged into the existing collection. Does mongorestore merge the records in the same collection or it will drop the existing collection before restoring the records? 回答1: mongorestore will only drop the existing collection if you use the --drop argument. If you don't use --drop , all documents will be inserted into the existing collection, unless a document with the same

Can mongorestore take a single url argument instead of separate arguments?

こ雲淡風輕ζ 提交于 2019-12-29 06:54:09
问题 If I have a mongo database URL of the following format mongodb://someUsername:somePassword@some.server.com:27017/some_collection Is there an easy way to give this to mongorestore without having to do mongorestore -u someUsername -p somePassword -h some.server.com:27017 -db some_collection /path/to/dump The reason I ask is because meteor mongo --url gives back a url of that form (and it looks like a standardized url format) but it expires in one minute. Because the password and host can be

MongoDB- backing up and restoring users and roles

我是研究僧i 提交于 2019-12-24 08:07:40
问题 What are best practices for synching users and roles between Mongo instances? On the same Windows machine, I am trying to copy MongoDB users and roles in the admin database from one Mongo instance to another. Authentication is 'on' for each instance. No combination of mongodump\mongorestore or mongoexport\mongoimport I have tried works. With mongodump\restore, the restore step displays: assuming users in the dump directory are from <= 2.4 (auth version 1) Failed: the users and roles