Ubuntu18.04 安装配置mongodb

一、安装

# 1. 更新
sudo apt-get update
# 2. 安装
sudo apt-get install -y mongodb
# 3. 查看是否安装成功
# a. 服务状态
sudo systemctl status mongodb
sudo service mongodb status
# 状态是active 即可
# b. 实际连接数据库
mongo --eval 'db.runCommand({ connectionStatus: 1 })'
# 4. 设置开机启动
sudo systemctl enable mongdb
# 5. 开启端口
sudo ufw allow 27017
sudo ufw status

二、开启远程连接

# 1. 编辑配置文件
sudo vim /etc/mongodb.conf
将服务器的IP地址添加到bindIP值

# 2. 重启服务
sudo systemctl restart mongodb

猜你喜欢

转载自www.cnblogs.com/wt7018/p/11910003.html