我确实为data / db提供了这条路径 /usr/local/Cellar/mongodb/3.2.6/data/db 执行以下步骤以创建绑定到mongodb文件夹 sudo mongod --directoryperdb --dbpath /usr/local/Cellar/mongodb/3.2.6/data/db --logpath /usr/local/Cella
/usr/local/Cellar/mongodb/3.2.6/data/db
执行以下步骤以创建绑定到mongodb文件夹
sudo mongod --directoryperdb --dbpath /usr/local/Cellar/mongodb/3.2.6/data/db --logpath /usr/local/Cellar/mongodb/3.2.6/log/mongodb.log --logappend -rest
在终端中初始化sudo mongod时,会出现以下错误:
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] MongoDB starting : pid=8107 port=27017 dbpath=/data/db 64-bit host=iMac-Krystyna-2.local 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] db version v3.2.6 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] allocator: system 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] modules: none 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] build environment: 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] distarch: x86_64 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] target_arch: x86_64 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] options: {} 2016-06-08T14:45:06.970+0200 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating 2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] dbexit: rc: 100
你能解释一下有什么问题吗?为了与MongoDB一起正常工作,你可以展示一些常见的做法吗?
您需要以root身份创建此目录要么你需要使用sudo,例如sudo mkdir -p / data / db
或者你需要做su – 成为超级用户,然后使用mkdir -p / data / db创建目录