|
Installation and Configuration
Installing MongoDB on Debian / Ubuntu Linux
Find the version of Linux
.
- Run uname -a from a terminal window
Download from browser and install
.
- Go to Downloads: www.mongodb.org/downloads
- Double click on the completed download filename
- Extract to an appropriate folder
- Create mongodb user
- Create /data/db
- Assign ownership to mongodb user
Install from the command line: Ubuntu Linux
.
- Import MongoDB public key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 - Configure software sources list:
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee /etc/apt/sources.list.d/mongodb.list - Install:
sudo apt-get install mongodb-10gen
Install from the command line: Debian Linux
.
- Import MongoDB public key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 - Configure software sources list:
echo "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" | sudo tee /etc/apt/sources.list.d/mongodb.list - Install:
sudo apt-get install mongodb-10gen
Start / Stop MongoDB
.
- Open another command prompt
- Start: sudo service mongod start
- Stop: sudo service mongod stop
- Restart: sudo service mongod restart
- Start after reboot:
Connect to MongoDB
.
- Open another command prompt
- Start the MongoDB service
- Connect to the MongoDB shell: mongo
- Use the default database: use mydb
- Save a test document: db.test.save({a:1})
- Find the test document: db.test.find()
|
|