试着看了这个,但只能找到类似的问题,但不一样。当我尝试使用'mongod'命令从终端启动mongodb时,我得到以下内容:
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] MongoDB starting : pid=861 port=27017 dbpath=/data/db 64-bit host=Dylans-MacBook-Pro-2.local
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] db version v3.4.2
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] allocator: system
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] modules: none
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] build environment:
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] distarch: x86_64
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-02-27T15:48:17.874+0000 I CONTROL [initandlisten] options: {}
2017-02-27T15:48:17.875+0000 I STORAGE [initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating
2017-02-27T15:48:17.875+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-02-27T15:48:17.875+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-02-27T15:48:17.875+0000 I CONTROL [initandlisten] now exiting
2017-02-27T15:48:17.875+0000 I CONTROL [initandlisten] shutting down with code:100
有什么想法吗?谢谢! (使用Mac OS 10.12)
答案 0 :(得分:3)
尝试在只读目录上创建锁定文件:/ data / db
基本上,您需要确保/ data / db目录是可写的。您可能手动创建它而无需写访问权。