1. Download
https://www.mongodb.com/download-center
2. PATH (全路径)
3. Create Data path
默认在根目录下的data/db. 尝试过在mongodb中建立 data/db作为数据路径,但还是报错。
As you can see from the picture above, I have created a "data/db" folder in the mongodb folder but it did not work.
4. Start MongoDB
As is shown below, the MongoDB server is started successfully.
命令总结:
# 添加全路径到PATH
~ export PATH=/Users/hannah/Develop/mongodb/bin:$PATH
# 创建数据路径
~ sudo mkdir -p /data/db
# 设置文件夹权限
~ sudo chown -R name /data
# 启动 MongoDB server
~ mongod
# 退出MongoDB
~ ctrl+C