How to copy a collection from one database to another in MongoDB

The best way is to do a mongodump then mongorestore. You can select the collection via: mongodump -d some_database -c some_collection [Optionally, zip the dump (zip some_database.zip some_database/* -r) and scp it elsewhere] Then restore it: mongorestore -d some_other_db -c some_or_other_collection dump/some_collection.bson Existing data in some_or_other_collection will be preserved. That way you can “append” a … Read more

How to select a single field for all documents in a MongoDB collection?

From the MongoDB docs: A projection can explicitly include several fields. In the following operation, find() method returns all documents that match the query. In the result set, only the item and qty fields and, by default, the _id field return in the matching documents. db.inventory.find( { type: ‘food’ }, { item: 1, qty: 1 … Read more

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