Skip to content

mongoDB windows 和linux下安装

windows

新建data/db文件夹
mongod --dbpath ../data/db
新建conf/mongo.conf文件
>>
storage:
	dbpath: path/to/data/db
<<
mongod -f  ../conf/mongod.conf
mongod --conf ../conf/mongod.conf

shell 连接
mongo --host=127.0.0.1 --port=27017

linux

#上传~解压
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-6.0.8.tgz

mv "" /opt/mongodb

mkdir -p /opt/mongodb/single/data/db 
mkdir -p /opt/mongodb/single/log
vim /opt/mongodb/single/mongod.conf
>>
systemLog:
  destination: file
  path: "/opt/mongodb/single/log/mongodb.log"
  logAppend: true
storage:
  dbPath: "/opt/mongodb/single/data/db"
  journal:
    enabled: true
processManagement:
#后台启动
  fork: true
net:
# 绑定ip
  bindIp: localhost,192.168.152.150
  port: 27017
<<
mongod -f /opt/mongodb/single/mongod.conf

使用mongoCampass 连接

shell
wget https://downloads.mongodb.com/compass/mongosh-1.6.0-linux-x64.tgz
mongosh