After the successful installation,you can start MongoDB.
You can start the mongod process by issuing the following command:
$ sudo systemctl start mongod
If you receive an error similar to the following when starting mongod:
i.e Failed to start mongod.service: Unit mongod.service not found.
Run the following command first:
$ sudo systemctl daemon-reload
Then run the start command above again,it should start
To verify that MongoDB has started successfully run :
$ sudo systemctl status mongod
You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:
$ sudo systemctl enable mongod
If you receive an error similar to the following image, when starting mongod:
As the command is unable to start the mongod process, review the /var/log/mongodb/mongod.log file, to find out the error messages and you can findout the “failed to unlink socket file /tmp/mongodb-27017 “ error.
Solution :
To fix the error, just delete the /tmp/mongodb-27017.sock file manually and start the mongod process. Now you can check the /tmp/mongodb-27017.sock permission again, the ownership is changed to the “mongodb” user as shown below :
Common error :
While running $ sudo apt-get upgrade, Ubuntu helps to upgrade the MongoDB automatically, and changed the mongodb-27017.sock ownership to root, and normally we start the ‘mongod’ process with user “mongodb”, causes the above error so we need to change ownership back to mongodb user.