Created
March 12, 2014 06:07
-
-
Save amolkhanorkar/9501740 to your computer and use it in GitHub Desktop.
mongoDB Installation on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongoDB | |
Installation on Ubuntu | |
sudo apt-get update | |
sudo apt-get install mongodb-10gen | |
OR | |
sudo apt-get install mongodb | |
Also see ref. http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages | |
Importing data to collection | |
Command for importing data to collection : | |
mongoimport -h [host] --port [port] -u [user] -d [database] -p [password] -c [collection] --file [file] | |
e.g. | |
mongoimport -h localhost --port 27017 -u weboniseUSER -d WEBONISE -p webonisePassword -c users --file users.json | |
Here, | |
Server Name : localhost | |
Port Number : 27017 | |
User Name : weboniseUSER | |
Password : webonisePassword | |
DataBase Name : WEBONISE | |
Collection : users (collection means table name) | |
File : users.json | |
For more help type "mongoimport" in terminal | |
Exporting data from collection | |
Command for exporting data from collection : | |
mongoexport -h [host] --port [port] -u [user] -d [database] -p[password] -c [collection] > json file 2> log file | |
e.g. | |
mongoexport -h localhost --port 27017 -u weboniseUSER -d WEBONISE -pwebonisePassword -c jobs > jobs.json 2> error.log | |
here, | |
Server Name : localhost | |
Port Number : 27017 | |
User Name : weboniseUSER | |
Password : webonisePassword | |
DataBase Name : WEBONISE | |
Collection : jobs (collection means table name) | |
JSON File : jobs.json | |
Error File : error.json | |
Note: Notice that the password is attached to option -p, I colored that option in above example :) | |
For more help type "mongoexport" in terminal | |
Set Default Path and Run MongoDB server in startup also remove lock file | |
Create mongod file with chmod +x permission | |
Copy and paste following lines into mongod file | |
#!/bin/bash | |
echo "webonise6186" | sudo -S rm /var/lib/mongodb/mongod.lock | |
echo "webonise6186" | sudo -S mongod --dbpath /var/lib/mongodb | |
Goto System -> Preferences -> Startup Application and click "Add", | |
Enter name, select location of mongod file (created by you), and comment. | |
Restart your PC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment