在官網下載安裝包:linux
https://www.mongodb.com/download-center/community
或者經過wget下載mongodb
而後下載到本地,解壓app
[root@xxx test]# ls mongodb-linux-x86_64-4.0.6.tgz [root@xxx test]# tar -zxvf mongodb-linux-x86_64-4.0.6.tgz mongodb-linux-x86_64-4.0.6/README mongodb-linux-x86_64-4.0.6/THIRD-PARTY-NOTICES mongodb-linux-x86_64-4.0.6/MPL-2 mongodb-linux-x86_64-4.0.6/LICENSE-Community.txt mongodb-linux-x86_64-4.0.6/bin/mongodump mongodb-linux-x86_64-4.0.6/bin/mongorestore mongodb-linux-x86_64-4.0.6/bin/mongoexport mongodb-linux-x86_64-4.0.6/bin/mongoimport mongodb-linux-x86_64-4.0.6/bin/mongostat mongodb-linux-x86_64-4.0.6/bin/mongotop mongodb-linux-x86_64-4.0.6/bin/bsondump mongodb-linux-x86_64-4.0.6/bin/mongofiles mongodb-linux-x86_64-4.0.6/bin/mongoreplay mongodb-linux-x86_64-4.0.6/bin/mongod mongodb-linux-x86_64-4.0.6/bin/mongos mongodb-linux-x86_64-4.0.6/bin/mongo mongodb-linux-x86_64-4.0.6/bin/install_compass [root@xxx test]# ls mongodb-linux-x86_64-4.0.6 mongodb-linux-x86_64-4.0.6.tgz
將解壓出的文件夾移動到/usr/local/下而且重命名爲mongodbspa
[root@xxx test]# mv mongodb-linux-x86_64-4.0.6 /usr/local/mongodb/ [root@xxx test]# cd /usr/local/mongodb/ [root@xxx mongodb]# ls bin LICENSE-Community.txt MPL-2 README THIRD-PARTY-NOTICES
建立文件夾data.net
[root@xxx mongodb]# mkdir data
建立文件logsrest
[root@uJZPqK149888 mongodb]# touch logs
進入/usr/local/mongodb/bin目錄下,啓動mongodb服務code
[root@xxx mongodb]# cd bin [root@xxx bin]# ls bsondump install_compass mongo mongod mongodump mongoexport mongofiles mongoimport mongoreplay mongorestore mongos mongostat mongotop [root@xxx bin]# ./mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend --port=27017 --fork about to fork child process, waiting until server is ready for connections. forked process: 80758 child process started successfully, parent exiting
進入/usr/local/mongodb/bin目錄下,啓動客戶端server
./mongo
vi /etc/profile blog
export MONGODB_HOME=/usr/local/mongodb export PATH=$PATH:$MONGODB_HOME/bin
保存後,重啓系統配置get
source /etc/profile
這樣就不用到文件夾中啓動mongo了。
參考:
https://blog.csdn.net/caofeiliju/article/details/80195036
https://blog.csdn.net/rzrenyu/article/details/79472508