MongoDB学习笔记:安装
本文更新于2025-09-20。
官网下载地址:https://www.mongodb.com/try/download/community
包括以下几个软件包:
- 社区版服务器(MongoDB Community Server):包含mongod命令。安装后的服务名为mongod。
- mongos:包含mongos命令。
- Shell(MongoDB Shell):包含mongosh命令。(MongoDB 6.0使用mongosh替换mongo)。
- 数据库工具(MongoDB Database Tools):包含mongodump、mongoexport、mongofiles、mongoimport、mongorestore、mongostat、mongotop命令。
注意:安装服务器时,若数据目录(通常为/var/lib/mongo/)有数据,不覆盖,并会使用其线路协议的版本。
在Debian下安装
安装社区版服务器(MongoDB Community Server)server
wget https://repo.mongodb.org/apt/debian/dists/bookworm/mongodb-org/7.0/main/binary-amd64/mongodb-org-server_7.0.12_amd64.deb
sudo dpkg -i mongodb-org-server_7.0.12_amd64.deb
安装社区版服务器(MongoDB Community Server)mongos
wget https://repo.mongodb.org/apt/debian/dists/buster/mongodb-org/4.4/main/binary-amd64/mongodb-org-mongos_4.4.5_amd64.deb
sudo dpkg -i mongodb-org-mongos_4.4.5_amd64.deb
安装Shell(MongoDB Shell)
wget https://downloads.mongodb.com/compass/mongodb-mongosh_2.2.15_amd64.deb
sudo dpkg -i mongodb-mongosh_2.2.15_amd64.deb
安装数据库工具(MongoDB Database Tools)
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian12-x86_64-100.10.0.deb
sudo dpkg -i mongodb-database-tools-debian12-x86_64-100.10.0.deb
在CentOS 7.5下安装
安装社区版服务器(MongoDB Community Server)server
wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/7.0/x86_64/RPMS/mongodb-org-server-7.0.22-1.el7.x86_64.rpm
sudo rpm -i mongodb-org-server-7.0.22-1.el7.x86_64.rpm
安装社区版服务器(MongoDB Community Server)mongos
wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/7.0/x86_64/RPMS/mongodb-org-mongos-7.0.22-1.el7.x86_64.rpm
sudo rpm -i mongodb-org-mongos-7.0.22-1.el7.x86_64.rpm
安装Shell(MongoDB Shell)
wget https://downloads.mongodb.com/compass/mongodb-mongosh-2.5.7.x86_64.rpm
sudo rpm -i mongodb-mongosh-2.5.7.x86_64.rpm
安装数据库工具(MongoDB Database Tools)
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel70-x86_64-100.13.0.rpm
sudo rpm -i mongodb-database-tools-rhel70-x86_64-100.13.0.rpm
在openEuler 22.03下安装
安装社区版服务器(MongoDB Community Server)server
wget https://repo.mongodb.org/yum/redhat/8/mongodb-org/8.2/x86_64/RPMS/mongodb-org-server-8.2.0-1.el8.x86_64.rpm
sudo rpm -i mongodb-org-server-8.2.0-1.el8.x86_64.rpm
安装社区版服务器(MongoDB Community Server)mongos
wget https://repo.mongodb.org/yum/redhat/8/mongodb-org/8.2/x86_64/RPMS/mongodb-org-mongos-8.2.0-1.el8.x86_64.rpm
sudo rpm -i mongodb-org-mongos-8.2.0-1.el8.x86_64.rpm
安装Shell(MongoDB Shell)
wget https://downloads.mongodb.com/compass/mongodb-mongosh-2.5.8.x86_64.rpm
sudo rpm -i mongodb-mongosh-2.5.8.x86_64.rpm
安装数据库工具(MongoDB Database Tools)
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel88-x86_64-100.13.0.rpm
sudo rpm -i mongodb-database-tools-rhel88-x86_64-100.13.0.rpm
使用tgz包安装
使用4.4.5,操作系统为Debian 10.5 (buster)。
包含mongod、mongo、mongos命令。
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-4.4.5.tgz
tar -xzv -f mongodb-linux-x86_64-debian10-4.4.5.tgz
cd mongodb-linux-x86_64-debian10-4.4.5/bin
./install_compass

浙公网安备 33010602011771号