I am trying to install mongodb on my Ubuntu 18.04 LTS, but it has the following error saying
You might want to run \'apt --fix-broken install\' to correct
mongod
command on ubuntu 18.04. $ sudo apt update
$ sudo apt install -y mongodb
$ sudo systemctl status mongodb
3a. You should see
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor
preset:enabled)
Active: active (running) since Sat 2019-03-11 10:45:01 UTC; 4min 13s ago
Docs: man:mongod(1)
Main PID: 2312 (mongod)
Tasks: 23 (limit: 1153)
CGroup: /system.slice/mongodb.service
└─2312 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config
/etc/mongodb.conf
port 27017
$ sudo ufw allow 27017
$ sudo ufw status
5a. You should see
Status: active
To Action From
-- ------ ----
27017 ALLOW Anywhere
27017 (v6) ALLOW Anywhere (v6)
5b. If it returns inactive
$ sudo ufw enable
Output:
Firewall is active and enabled on system startup.
/
directory to see if there is a data/db
directory, if not: $ sudo mkdir -p /data/db
mongod
first you need stop mongodb: $ sudo systemctl stop mongodb
mongod
: $ sudo mongod