系统环境
Ubuntu20.04
首先安装gnupg软件包
sudo apt-get install gnupg
导入包管理系统使用的公钥
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
添加mongoDB存储库
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
更新存储库
sudo apt-get update
安装mongoDB:
sudo apt install mongodb-org
启动mongoDB服务
sudo systemctl start mongod.service
sudo systemctl enable mongod
查看mongoDB服务的状态
sudo systemctl status mongod
验证安装是否成功完成
mongo --eval 'db.runCommand({ connectionStatus: 1 })'
配置mongoDB
vim /etc/mongod.conf
mongodb服务命令
重启
sudo systemctl restart mongod
查看状态
sudo systemctl status mongod
停止
sudo systemctl stop mongod
关闭开机启动
sudo systemctl disable mongod
进入mongoDB shell
mongo