For this example I’ll be using MongoHQ as the cloud host. I prefer MongoHQ over MongoLab because the web interface actually lets you edit and manage your data, which is great for making quick small tweaks.
Step 1 - Create a new database in MongoHQ
I start with a Free 16 MB collection. The next page you’re taken to shows you the address for the database and will look something like staff.mongohq.com:10023/DbName
Step 2 - Create a Database User
Click on the Database Users tab and add a user. Leave the Read Only boxed unchecked.
Step 3 - Prep your local data for transfer
On your machine open a command prompt and navigate to your Mongo bin directory or wherever the mongo.exe file is located.
Type mongodump -d DatabaseName where DatabaseName is the actual name of your database
There will be a new folder in the directory named dump and in there another folder named after your database.
Step 4 - Transfer the data to the cloud
Type mongorestore -h staff.mongohq.com:10023 -d DatabaseName -u admin -p password C:\Mongo\dump\DatabaseName (Make sure to substitute the appropriate values).
Verify on MongoHQ’s collections tab that the data was transferred successfully.
No comments:
Post a Comment