# Mongo Setup
Download mongo from the web
Unzip the contents into installs folder
Rename the unzipped folder to
mongodbAdd mongo to path
export MONGO_HOME=~/installs/mongodb
export PATH=$MONGO_HOME/bin:$PATH
- Create a folder for mongo data
~>mkdir db db/mongo db/mongo/data
- Create
mongodbconfigunderinstals/<mongo_intsallation_folder>/binwith the following configuration: Replace<user_home>by the actual directory under which db folder is created. Usually for ubuntu ->/home/<user_name>for mac ->/Users/<user_name>
mongodbconfig
dbpath = <user_home>/db/mongo/data
logpath = <user_home>/db/mongo/mongodb.log
logappend = true
port = 27017
fork = true
bind_ip = 0.0.0.0
- Also create mongostart & mongostop script
mongostart.sh
sudo ~/installs/<mongo_intsallation_folder>/bin/mongod --config ~/installs/<mongo_intsallation_folder>/bin/mongodbconfig
mongostop.sh
#!/bin/bash
pid=`ps -aef | grep mongod | grep config | tr -s " " | cut -f3 -d " "`;
if [ "${pid}" != "" ]; then
sudo kill -2 ${pid};
fi
warning Note
the pid field could differ based on os, for macOS its -f3 & ubuntu -f2 (?)
- Open command-line & start mongo server using command mongostart
~>mongostart
about to fork child process, waiting until server is ready for connections.
forked process: 22515
child process started successfully, parent exiting
- You can whether mongo is running by entering into mongo shell
~>mongo
MongoDB shell version v3.4.14-16-gaf4ea84
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.14-16-gaf4ea84
Server has startup warnings:
2018-05-18T11:30:24.049+0530 I CONTROL [initandlisten]
2018-05-18T11:30:24.049+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-05-18T11:30:24.049+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-05-18T11:30:24.050+0530 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-05-18T11:30:24.050+0530 I CONTROL [initandlisten]
> db.show
test.show
> exit
Bye
- Now you can connect to localhost:27017 through Studio3T
- Further reference on mongo & studio3T: