确保最新的包
sudo apt update
安装mongdb
sudo apt install mongodb
相关命令
// 查看状态sudo systemctl status mongodb// 启动mongodbsudo systemctl start mongodb// 重启mongodbsudo systemctl restart mongodb// 停止mongodbsudo systemctl stop mongodb
设置是否跟随系统启动
// 根据系统启动sudo systemctl enable mongodb// 禁止跟随系统启动sudo systemctl disable mongodb
卸载
sudo systemctl stop mongodbsudo apt purge mongodbsudo apt autoremove
外网无法访问
原因是系统默认是127.0.0.1访问。需要修改成0.0.0.0
// 设置访问权限cd /etcsudo vim mongodb.conf# bind_ip = 127.0.0.1bind_ip = 0.0.0.0
重启mongodb ok了
