(Mac) Cannot start mongo, via "mongod" command - mongodb

Just trying to get up and started using the "mongod" command...
I've already looked at the following:
Cannot start mongo db
Trouble Starting MongoDB (Mac) - Code: 100
... and many other forum posts.
This is what I got in my terminal:
#####-MacBook-Pro-2:p2w4-back_end ashesmachine$ mongod
2020-05-17T13:53:02.341-0700 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-17T13:53:02.345-0700 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] MongoDB starting : pid=57712 port=27017 dbpath=/data/db 64-bit host=#####-MacBook-Pro-2.local
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] db version v4.2.6
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] allocator: system
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] modules: none
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] build environment:
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] distarch: x86_64
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] target_arch: x86_64
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] options: {}
2020-05-17T13:53:02.346-0700 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-05-17T13:53:02.347-0700 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-05-17T13:53:02.347-0700 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-05-17T13:53:02.347-0700 I CONTROL [initandlisten] now exiting
2020-05-17T13:53:02.347-0700 I CONTROL [initandlisten] shutting down with code:100

You should create the data/db directory before starting mongodb. Something like mkdir -p /data/db

This worked for me:
sudo mongod --dbpath ~/Documents/data/mongo-db

Related

Getting error running 'Mongod' to start mongodb

I'm trying to run mongodb, but typing 'mongod' is giving me the error below, do you know how to fix it?
mongod
2021-05-14T15:12:30.819-0400 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] MongoDB starting : pid=60494 port=27017 dbpath=/data/db 64-bit host=Chris.local
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] db version v4.2.3
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] allocator: system
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] modules: none
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] build environment:
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] distarch: x86_64
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] target_arch: x86_64
2021-05-14T15:12:30.846-0400 I CONTROL [initandlisten] options: {}
2021-05-14T15:12:30.848-0400 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2021-05-14T15:12:30.849-0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2021-05-14T15:12:30.849-0400 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2021-05-14T15:12:30.849-0400 I CONTROL [initandlisten] now exiting
2021-05-14T15:12:30.849-0400 I CONTROL [initandlisten] shutting down with code:100
Log file usually contains the clue to debug
You can see in the log
2021-05-14T15:12:30.848-0400 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
The directory /data/db is not found, you need to create this directory and make sure mongod has write permission to this folder.

How do I change mongodb data directory on windows

My MongoDB server was running fine until yesterday. But then I encountered this error:
2020-03-31T10:21:25.981+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-03-31T10:21:25.986+0530 I CONTROL [initandlisten] MongoDB starting : pid=7544 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-IP084D8
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] db version v4.2.3
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] allocator: tcmalloc
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] modules: none
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] build environment:
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] distmod: 2012plus
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] distarch: x86_64
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] target_arch: x86_64
2020-03-31T10:21:25.988+0530 I CONTROL [initandlisten] options: {}
2020-03-31T10:21:25.990+0530 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2020-03-31T10:21:25.990+0530 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-03-31T10:21:25.990+0530 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-03-31T10:21:25.990+0530 I CONTROL [initandlisten] now exiting
2020-03-31T10:21:25.991+0530 I CONTROL [initandlisten] shutting down with code:100
I do not know how the data path got changed. I have to change the MongoDB data path from C:\data\db\ to C:\Program Files\MongoDB\Server\4.2\data, so I tried changing it using the following command, but it doesn't recognize the path:
mongod --dbpath C:\Program Files\MongoDB\Server\4.2\data
What should be the format of the path to be entered here?
Use CMD as a system administrator and type
mongod --dbpath C:\myfolder\myproj\data\db"

Installing and Running MongoDB - Many Errors on Mac

I'm trying to install mongoDB on my Mac. However, I'm running into a lot of issues.
I first installed mongoDB using Homebrew by running the following commands:
brew tap mongodb/brew
brew install mongodb-community#4.2
Then ran it using:
brew services start mongodb-community#4.2
Everything looks fine at this point, until I try running in the terminal:
mongod
At first I thought the issue was that I didn't create the /data/db folder, so I ran:
sudo mkdir -p /data/db
This did not work.
I then found an article stating Mac users need to run:
sudo mkdir -p /System/Volumes/Data/data/db
This worked.. then I ran:
mongod --dbpath /System/Volumes/Data/data/db
And received the following:
2020-02-09T20:36:07.667-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] MongoDB starting : pid=65406 port=27017 dbpath=/System/Volumes/Data/data/db 64-bit host=user-MacBook-Pro.local
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] db version v4.2.3
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] allocator: system
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] modules: none
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] build environment:
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] distarch: x86_64
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] options: { storage: { dbPath: "/System/Volumes/Data/data/db" } }
2020-02-09T20:36:07.673-0500 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2020-02-09T20:36:07.673-0500 I CONTROL [initandlisten] now exiting
2020-02-09T20:36:07.673-0500 I CONTROL [initandlisten] shutting down with code:48
I tried running:
sudo chown -Rv user /System/Volumes/Data/data/db
mongod
Then received the following:
2020-02-09T20:36:52.247-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] MongoDB starting : pid=65410 port=27017 dbpath=/data/db 64-bit host=user-MacBook-Pro.local
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] db version v4.2.3
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] allocator: system
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] modules: none
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] build environment:
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] distarch: x86_64
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] options: {}
2020-02-09T20:36:52.250-0500 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2020-02-09T20:36:52.250-0500 I CONTROL [initandlisten] now exiting
2020-02-09T20:36:52.250-0500 I CONTROL [initandlisten] shutting down with code:48
For the SocketException, I tried:
mongod --port 27018
And received:
2020-02-09T20:37:39.191-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] MongoDB starting : pid=65414 port=27018 dbpath=/data/db 64-bit host=user-MacBook-Pro.local
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] db version v4.2.3
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] allocator: system
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] modules: none
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] build environment:
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] distarch: x86_64
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] options: { net: { port: 27018 } }
2020-02-09T20:37:39.196-0500 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-02-09T20:37:39.196-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-02-09T20:37:39.196-0500 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-02-09T20:37:39.196-0500 I CONTROL [initandlisten] now exiting
2020-02-09T20:37:39.196-0500 I CONTROL [initandlisten] shutting down with code:100
I just can't seem to figure out what's going on, since I've just been following all the steps I've found on StackOverflow from other people with this exact issue.
After doing some more research and viewing the comments above, it appears that when installing MongoDB through homebrew you will use the following commands:
brew services start mongodb-community
Then in a new tab:
mongo
This will start mongo successfully. I'm still not 100% sure why mongod kicks back errors, but for all I know, the above works.

Set DB path for Mongodb via terminal

Trying to initialize mongod, but getting below error. I know DB path is not set correctly. How can I set DB path in Mac?
The path I'm trying to set is "/Users/kopal/Downloads/mongodb-macos-x86_64-4.2.1/bin/data"
2019-11-02T22:11:51.748-0400 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-11-02T22:11:51.777-0400 I CONTROL [initandlisten] MongoDB starting : pid=2292 port=27017 dbpath=/data/db 64-bit host=Kopals-MacBook-Air.local
2019-11-02T22:11:51.777-0400 I CONTROL [initandlisten] db version v4.2.1
2019-11-02T22:11:51.777-0400 I CONTROL [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-11-02T22:11:51.777-0400 I CONTROL [initandlisten] allocator: system
2019-11-02T22:11:51.777-0400 I CONTROL [initandlisten] modules: none
2019-11-02T22:11:51.777-0400 I CONTROL [initandlisten] build environment:
2019-11-02T22:11:51.777-0400 I CONTROL [initandlisten] distarch: x86_64
2019-11-02T22:11:51.777-0400 I CONTROL [initandlisten] target_arch: x86_64
2019-11-02T22:11:51.778-0400 I CONTROL [initandlisten] options: {}
2019-11-02T22:11:51.786-0400 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2019-11-02T22:11:51.789-0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-11-02T22:11:51.789-0400 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-11-02T22:11:51.789-0400 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-11-02T22:11:51.790-0400 I CONTROL [initandlisten] now exiting
2019-11-02T22:11:51.790-0400 I CONTROL [initandlisten] shutting down with code:100```
When you start mongod, add the --dbpath option such as:
mongod --dbpath "/Users/kopal/Downloads/mongodb-macos-x86_64-4.2.1/bin/data"
or set the path in the mongod.conf as follows.
storage:
dbPath: "/Users/kopal/Downloads/mongodb-macos-x86_64-4.2.1/bin/data"

How to fix mongodb Error: Network is unreachable

I get this error, when I try to connect to MongoDB
Error:
Network is unreachable.
Running mongod before mongo shell didn't help .
When I restart my computer it works!!!Anyway I get that error again, something like 30 minutes later.
This is output from cmd, when I run command mongod
C:\Program Files\MongoDB\Server\4.0\bin>mongod
2019-04-26T18:50:26.559+0400 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-04-26T18:50:26.562+0400 I CONTROL [initandlisten] MongoDB starting : pid=1092 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-47AK9D5
2019-04-26T18:50:26.562+0400 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-04-26T18:50:26.563+0400 I CONTROL [initandlisten] db version v4.0.7
2019-04-26T18:50:26.563+0400 I CONTROL [initandlisten] git version: 1b82c812a9c0bbf6dc79d5400de9ea99e6ffa025
2019-04-26T18:50:26.564+0400 I CONTROL [initandlisten] allocator: tcmalloc
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] modules: none
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] build environment:
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] distmod: 2008plus-ssl
2019-04-26T18:50:26.566+0400 I CONTROL [initandlisten] distarch: x86_64
2019-04-26T18:50:26.566+0400 I CONTROL [initandlisten] target_arch: x86_64
2019-04-26T18:50:26.567+0400 I CONTROL [initandlisten] options: {}
2019-04-26T18:50:26.568+0400 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2019-04-26T18:50:26.568+0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-04-26T18:50:26.568+0400 I CONTROL [initandlisten] now exiting
2019-04-26T18:50:26.568+0400 I CONTROL [initandlisten] shutting down with code:100
Edit: I found a problem. MongoDB Server turns off automatically. Just change service startup type to Manual.
MongoDB Server Properties