MongoDB无法运行MacOS


Murats-Air:~ murat$ mongod
2020-05-26T14:28:14.858-0400 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-26T14:28:14.862-0400 W  ASIO     [main] No TransportLayer configured during NetworkInterface startup
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten] MongoDB starting : pid=706 port=27017 dbpath=/data/db 64-bit host=Murats-Air.home
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten] db version v4.2.7
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten] git version: 51d9fe12b5d19720e72dcd7db0f2f17dd9a19212
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten] allocator: system
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten] modules: none
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten] build environment:
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten]     distarch: x86_64
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten]     target_arch: x86_64
2020-05-26T14:28:14.863-0400 I  CONTROL  [initandlisten] options: {}
2020-05-26T14:28:14.864-0400 I  STORAGE  [initandlisten] exception in initAndListen: 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., terminating
2020-05-26T14:28:14.865-0400 I  NETWORK  [initandlisten] shutdown: going to close listening sockets...
2020-05-26T14:28:14.865-0400 I  -        [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-05-26T14:28:14.865-0400 I  CONTROL  [initandlisten] now exiting
2020-05-26T14:28:14.865-0400 I  CONTROL  [initandlisten] shutting down with code:100

我无法解决问题。我曾试图杀死所有进程 mongod 上没有正在运行的进程。

我尝试创建/data/db 目录,但出现错误"它是只读的"。谁能说出这里的问题是什么。

您可以尝试使用本地数据目录,例如

mkdir mongodata
mongod --dbpath=./mongodata

如果有效,请确认您在/data/db文件夹上设置了适当的权限。

通常对于开发环境,我建议不要在某些全局/data/db文件夹中运行内容并使用本地每个项目的文件夹,或者在用户目录中创建一个专用的数据文件夹并将其设置在配置文件中。最后一个更高级的选项是运行 mongodb docker 容器,如果你对这些容器感到满意。

我通过使用手动运行方法解决了我的问题:

mongod --dbpath /usr/local/var/mongodb --logpath/usr/local/var/log/mongodb/mongo.log --fork

每次我使用此代码运行时,然后使用mongo

最新更新