在输入“sudo pkill -f mongod”命令后,无法再运行mongod命令启动

4
过去几天,“mongod”命令一直可以正常运行,但在我的终端中输入“sudo pkill -f mongod”命令后出现了问题。以下是我执行“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}}
我已经找到了一个临时解决方案,就是输入"mongod --dbpath /usr/local/var/mongodb"。如何撤销这个操作,以便可以通过输入"mongod"来启动数据库连接?

编辑:包括终端输出


1
http://idownvotedbecau.se/noexceptiondetails/ - D. SM
5个回答

2
如果您的操作系统是OS X,并且mongodb是通过Homebrew安装的,请尝试以下操作:
brew services restart mongodb-community 
brew services start mongodb-community

1
重新启动时不需要启动 mongodb-community。 - Avshalom N. Israel

1
在C盘中创建名为data的文件夹,然后在data文件夹内创建db文件夹,并重新运行命令,它将起作用。

这意味着与另一个答案提出了相同的建议。 - General Grievance

1

我解决了同样的问题,请尝试以下步骤:

  1. 数据目录为 C:\data\db\

  2. 以管理员身份运行命令提示符 C:\Program Files\MongoDB\Server\4.4\data\


0

检查您当前的目录。如果您不在根目录下,

cd ~

使用此命令进入根目录,然后运行mongod命令。

0

尝试以下命令。如果仍然无法正常工作,请在重启计算机后再试。

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接