Step 1:
Go to below location
and install mongoDB by following the instructions.
In my
case, I installed MongoDB on my MacBook.
Step 2:
Add mongoDB instance
path to system path. In Mac, I executed below command.
echo
'export PATH="/usr/local/opt/mongodb-community@4.0/bin:$PATH"'
>> ~/.bash_profile
Reload
bash profile by executing below command.
source
~/.bash_profile
Step 3:
Run MongoDB by
executing below command.
mongod
--config /usr/local/etc/mongod.conf
Above
command starts the mongoDB instance based on the configurations provided in
'mongodnormal.conf' file.
$mongod --config /usr/local/etc/mongod.conf
2019-08-12T14:51:00.413+0530 I STORAGE [main] Max cache overflow file size custom option: 0
Step 4:
Open other terminal
and execute the command ‘mongo’ to connect to the mongoDB instance.
$mongo
MongoDB shell version v4.0.12
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("26964183-1047-481a-a7f7-836ba701fc9f") }
MongoDB server version: 4.0.12
Server has startup warnings:
2019-08-12T14:51:01.213+0530 I CONTROL [initandlisten]
2019-08-12T14:51:01.213+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-08-12T14:51:01.213+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-08-12T14:51:01.213+0530 I CONTROL [initandlisten]
2019-08-12T14:51:01.213+0530 I CONTROL [initandlisten]
2019-08-12T14:51:01.213+0530 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
If you are
able to successfully connect to the mongoDB instance, then you are good to go.
As you see
the console messages, you can find below url.
mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
It means
that the mongoDB instance is running on port. 27017.
No comments:
Post a Comment