To Install and Getting started with MongoDB refer the below links
How to access Mongo instance
- Open a terminal session or command window.
- For a local connection to mongod, at the operating system prompt, enter the following command to start the mongo executable:
[mongo@MongoServer1 ~]$ mongo
The shell automatically attempts to connect to a MongoDB server on startup, so make sure you start mongod before starting the shell.
- For remote connections, we can connect your shell to any MongoDB instance that your machine can reach.
- To connect to amongod on a different machine or port, specify the hostname, port, and database when starting the shell
- At the operating system prompt, enter the following command to start the mongo executable:
[mongo@MongoServer2 ~]$ mongo MongoServer1:27017/foobar
- We can also start the mongo shell without connecting to any mongod server
[mongo@MongoServer1 ~]$ mongo –nodb
We can connect to the mongod server at a later point in time, by running :
>conn = new Mongo(“some-host:30000”)
>db = conn.getDB(“test”)