tar -zxvf filename.tgz
mkdir mongodb
mv mongodb-3.4.4 mongodb
cd mongodb
mkdir data
mkdir logs
cd logs/
touch mongo.log
cd ..
mkdir etc
cd etc
vi mongo.conf
dbpath=/mongodb/data
logpath=/mongodb/logs/mongo.log
logappend=true
journal=true
quiet=true
port=27017
:wq
cd ..
cd mongodb-3.4.4/bin/
mongod -f /mongodb/etc/mongo.conf
cd /
ln -s /mongodb/mongodb-3.4.4/bin/mongo /usr/local/bin/mongo
ln -s /mongodb/mongodb-3.4.4/bin/mongod /usr/local/bin/mongod
mongo
连接失败的话就先本地连接mongodb
ssh username@ip
mongod -f /mongodb/etc/mongo.conf
然后服务器根目录再输入
mongo