Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MongoDB: Difference between revisions

From iFixWiki
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
MongoDB is a database used to manage and create databases.
MongoDB is a database used to manage and create databases.
= Useful commands =
== Completely uninstall MongoDB ==
If you've messed up your MongoDB installation and want to completely uninstall use these commands<ref>https://askubuntu.com/a/1054726</ref>:
# sudo service mongod stop
# sudo apt-get purge mongodb-org*
# sudo rm -r /var/log/mongodb
# sudo rm -r /var/lib/mongodb


= Issues =
= Issues =
Line 20: Line 29:
# sudo systemctl start mongod
# sudo systemctl start mongod
# sudo systemctl status mongod
# sudo systemctl status mongod
== MongoDB fails to start immediately after installation ==
When running the command ''sudo systemctl start mongod'' an error will appear saying:
Failed to start mongod.service: Unit mongod.service not found.
'''Solution'''
Enter the command:
sudo systemctl enable mongod
This will link the service and allow it to start.
= References =
[[Category:Website Software]]

Latest revision as of 01:17, 19 February 2020

MongoDB is a database used to manage and create databases.

Useful commands[edit]

Completely uninstall MongoDB[edit]

If you've messed up your MongoDB installation and want to completely uninstall use these commands[1]:

  1. sudo service mongod stop
  2. sudo apt-get purge mongodb-org*
  3. sudo rm -r /var/log/mongodb
  4. sudo rm -r /var/lib/mongodb

Issues[edit]

MongoDB fails to start[edit]

When running the command sudo systemctl status mongod the MongoDB server will fail to start with the message (code=exited, status=62)

Solution

Attempt to repair the MongoDB installation by running the command:

sudo mongod --repair

If this command fails and it shows the error Data directory /data/db not found create the directory using this command:

sudo mkdir -p /data/db

Then restart mongodb:

  1. sudo systemctl stop mongod
  2. sudo systemctl start mongod
  3. sudo systemctl status mongod

MongoDB fails to start immediately after installation[edit]

When running the command sudo systemctl start mongod an error will appear saying:

Failed to start mongod.service: Unit mongod.service not found.

Solution

Enter the command:

sudo systemctl enable mongod

This will link the service and allow it to start.

References[edit]