-
下载
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.1.tgz -
解压
tar -zxvf mongodb-linux-x86_64-4.0.1.tgz -
改名字
mv mongodb-linux-x86_64-4.0.1 mongodb -
创建文件夹:db用来存放数据库、logs用来存放日志
cd mongodb
mkdir db logs -
创建配置文件
cd bin
vi mongodb.confdbpath=/opt/mongodb/db 数据存放位置
logpath=/opt/mongodb/logs/mongodb.log 日志存放位置
port=27017 端口
fork=true 是否后台运行 -
绑定ip和配置文件
./mongod --bind_ip 127.0.0.1 -f mongodb.conf -
修复的方式启动
bin/mongod -f /opt/mongodb/bin/mongodb.conf --repair
如果遇到
ERROR: child process failed, exited with error number 100
To see additional information in this output, start without the “–fork” option.
则删除之前在bin目录下创建的db和logs文件夹,删除后重新创建db和logs文件夹 -
开机启动
vi /etc/rc.d/rc.local
添加
/opt/mongodb/bin/mongod --bind_ip 127.0.0.1 -f /opt/mongodb/bin/mongodb.conf -
进入数据库
./mongo -
创建链接
ln -s /opt/mongodb/bin/mongo /usr/bin/mongo
Linux下安装mongodb
最新推荐文章于 2025-03-18 14:18:12 发布