运行时:
mongod
我明白了:
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] MongoDB starting : pid=1160 port=27017 dbpath=/data/db 64-bit host=Interstellar
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] db version v3.4.4
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] allocator: system
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] modules: none
2017-04-30T11:19:56.234+0600 I CONTROL [initandlisten] build environment:
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] distarch: x86_64
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] target_arch: x86_64
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] options: {}
2017-04-30T11:19:56.235+0600 I STORAGE [initandlisten] exception in
initAndListen: 29 Data directory /data/db not found., terminating
2017-04-30T11:19:56.235+0600 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-04-30T11:19:56.235+0600 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] now exiting
2017-04-30T11:19:56.235+0600 I CONTROL [initandlisten] shutting down with code:100
我遇到了麻烦,急需帮助
答案 0 :(得分:0)
问题是没有/ data / db目录。请发出以下命令:
sudo mkdir -p /data/db
如果您不担心过于广泛地打开权限,但只是想确保mongodb有权启动,您也可以发出这些命令。如果单独的上述命令无法解决问题,他们可能会解决您遇到的任何问题。
cd /
sudo chmod -R 777 data
答案 1 :(得分:0)
问题在于,如果您运行“ mongod”,则默认路径为/ usr / data。几乎所有的macOS Catalina都不接受在其中创建可写文件夹。因此,经过长时间的研究,无论是在此处还是在reddit中,我最终都启动并运行了服务器(mongod和Mongo)。请尝试以下步骤:
mkdir -p /System/Volumes/Data/data/db
sudo chown -Rv <your_user_name> /System/Volumes/Data/data/db
sudo mongod --dbpath /System/Volumes/Data/data/db
这可能会运行mongod并启动服务器。打开另一个终端选项卡,然后键入Mongo。
答案 2 :(得分:0)
第一步
brew services start mongodb/brew/mongodb-community@4.4
第二步
cd /Users
whoami
cd to your whoami directory
mkdir data
cd data
mkdir db
mongod --dbpath ~/data/db
第三步
mongo