1.下载,解压缩,移动
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.5.tgz
gunzip mongodb-linux-x86_64-3.6.5.tgz
tar -xvf mongodb-linux-x86_64-3.6.5.tar
mv mongodb-linux-x86_64-3.6.5 /usr/local/mongodb
2.配置mongodb.conf文件
cd /usr/local/mongodb
vi mongodb.conf
dbpath = /usr/local/mongodb/db # 设置日志文件的存放目录及其日志文件名(根据实际的logs文件夹的路径填写) logpath = /usr/local/mongodb/logs/mongodb.log # 设置端口号(默认的端口号是 27017) port = 27017 # 设置为以守护进程的方式运行,即在后台运行 fork = true nohttpinterface = true # idae - MongoDB config end
3.创建/usr/local/mongodb/data/db/
cd /usr/local/mongodb
mkdir data/db
./mongod --dbpath=/usr/local/mongodb/data/db/
./mongo
4.配置mongo到系统变量
vi /etc/profile
末尾添加
export MONGODB_HOME=/usr/local/mongodb
export PATH=$PATH:$MONGODB_HOME/bin
启动mongo
https://www.jianshu.com/p/06e3f8e68fac