'Can no longer run mongod command to start after typing "sudo pkill -f mongod"

The "mongod" command had been working fine for the past few days until I typed the command "sudo pkill -f mongod" in my terminal. Here is the result after I issue "mongod".


{"t":{"$date":"2020-08-16T13:32:49.543-04:00"},"s":"I", 
"c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically
disabling TLS 1.0, to force-enable TLS 1.0 specify
--sslDisabledProtocols 'none'"} {"t":{"$date":"2020-08-16T13:32:49.546-04:00"},"s":"W",  "c":"ASIO",  
"id":22601,   "ctx":"main","msg":"No TransportLayer configured during
NetworkInterface startup"}
{"t":{"$date":"2020-08-16T13:32:49.546-04:00"},"s":"I", 
"c":"NETWORK",  "id":4648602, "ctx":"main","msg":"Implicit TCP
FastOpen in use."}
{"t":{"$date":"2020-08-16T13:32:49.546-04:00"},"s":"I", 
"c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB
starting","attr":{"pid":718,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"Georges-MacBook-Pro.local"}}
{"t":{"$date":"2020-08-16T13:32:49.546-04:00"},"s":"I", 
"c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build
Info","attr":{"buildInfo":{"version":"4.4.0","gitVersion":"563487e100c4215e2dce98d0af2a6a5a2d67c5cf","modules":[],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-08-16T13:32:49.546-04:00"},"s":"I", 
"c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating
System","attr":{"os":{"name":"Mac OS X","version":"19.6.0"}}}
{"t":{"$date":"2020-08-16T13:32:49.546-04:00"},"s":"I", 
"c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set
by command line","attr":{"options":{}}}
{"t":{"$date":"2020-08-16T13:32:49.548-04:00"},"s":"E", 
"c":"STORAGE",  "id":20557,   "ctx":"initandlisten","msg":"DBException
in initAndListen, terminating","attr":{"error":"NonExistentPath: Data
directory /data/db not found. Create the missing directory or specify
another path using (1) the --dbpath command line option, or (2) by
adding the 'storage.dbPath' option in the configuration file."}}
{"t":{"$date":"2020-08-16T13:32:49.548-04:00"},"s":"I", 
"c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown:
going to close listening sockets"}
{"t":{"$date":"2020-08-16T13:32:49.548-04:00"},"s":"I",  "c":"-",     
"id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow
Control ticket acquisitions."}
{"t":{"$date":"2020-08-16T13:32:49.548-04:00"},"s":"I", 
"c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now
exiting"} {"t":{"$date":"2020-08-16T13:32:49.548-04:00"},"s":"I", 
"c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting
down","attr":{"exitCode":100}}

I have found a temporary solution which is by typing "mongod --dbpath /usr/local/var/mongodb". How can I undo this so that I can start the db connection by issuing "mongod"?

edit: included terminal output



Solution 1:[1]

If your O.S is OS X and mongodb is installed via Homebrew try:

brew services restart mongodb-community 
brew services start mongodb-community

Solution 2:[2]

Same Problem I solved Please try

  1. Data directory C:\data\db\

  2. Run administrator command prompt C:\Program Files\MongoDB\Server\4.4\data\

Solution 3:[3]

Try Below commands. If still not work, try after restart your pc.

sudo service mongod restart
sudo service mongod stop
sudo service mongod start

Solution 4:[4]

Make a folder in C drive named data and inside data make db folder and rerun the command it will work.

Solution 5:[5]

Check your current directory. If you are not in your root,

cd ~

use this command to get to the root and now run the mongod command.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 anajuliabit
Solution 2 Pawan Kumar patel
Solution 3 Rahul Beniwal
Solution 4 PK Maan
Solution 5 Kiran M P