mac上安装mongodb的坑

mac上安装mongodb可以使用brew install mongodb,然后等结束之后可以直接运行.mongod尝试启动mongodb的服务,这时候会提示大概如下错误


2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] MongoDB starting : pid=5176 port=27017 dbpath=/data/db 64-bit host=chenpingdeMac.local
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] db version v3.6.0
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] git version: a57d8e71e6998a2d0afde7edc11bd23e5661c915
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] allocator: system
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] modules: none
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] build environment:
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] distarch: x86_64
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] target_arch: x86_64
2017-12-24T03:52:00.372-0800 I CONTROL [initandlisten] options: {}
2017-12-24T03:52:00.373-0800 I STORAGE [initandlisten] exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db, terminating
2017-12-24T03:52:00.373-0800 I CONTROL [initandlisten] now exiting
2017-12-24T03:52:00.373-0800 I CONTROL [initandlisten] shutting down with code:100


或者错误为/data/db文件夹不存在,这时候就需要手工创建文件夹,直接使用mkdir -p /data/db 会提示权限不足,使用sudo mkdir -p /data/db 创建之后在运行就会提示上面的错误。切到/目录下使用ls -l查看权限
mac上安装mongodb的坑_第1张图片
发现文件目录权限是在root的,而我想要的是在chenping目录下,所以使用命令sudo chown -R chenping /da 修改父目录的所属用户,我就把它修改成chenping,实际使用中根据需要修改。

你可能感兴趣的:(Python)