2

How to Install and Configure MongoDB on Ubuntu

 1 year ago
source link: https://www.laravelcode.com/post/how-to-install-and-configure-mongodb-on-ubuntu
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to Install and Configure MongoDB on Ubuntu

  637 views

  10 months ago

Ubuntu

In this article, we will share with you how to install MongoDB in ubuntu. MongoDB is one of the open-source database and currently most used in modern web applications for high performance. MongoDB is JSON based database you can use MongoDB in most off programing language but it mostly uses with nodejs.

We are here show you all installation process step by step so, please follow this step and easily configure and install MongoDB in your local system.

Step - 1 : Adding the MongoDB Repository

Before installing MongoDB you should install these repositories for a new updated version, in ubuntu is already included. simply run following command in your Ubuntu terminal.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

After running this command you make sure you get the following output in the terminal.

Executing: /tmp/tmp.3JTuFvsumc/gpg.1.sh --keyserver
hkp://keyserver.ubuntu.com:80
--recv
EA312927
gpg: requesting key EA312927 from hkp server keyserver.ubuntu.com
gpg: key EA312927: public key "Totally Legit Signing Key <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Now run following command.

sudo apt-get update

Step - 2 : Installing and Verifying MongoDB

Now, run the following command to install MongoDB.

sudo apt-get install -y mongodb-org
OR
sudo apt-get install mongodb

This command will install the latest several packages for MongoDB.

After doing this process then go this directory root /etc/systemd/system/ and run the following command.

sudo nano /etc/systemd/system/mongodb.service

When you run this command then mongodb.service file open in ubuntu's nano editor and you show output looks like this.

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

Next, start the newly created service with systemctl.

sudo systemctl start mongodb

After running this command then check systemctl status this started properly or not using the following command.

sudo systemctl status mongodb

Then check your output look like this.

● mongodb.service - An object/document-oriented database
   Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-12-16 12:25:28 IST; 4min 4s ago
     Docs: man:mongod(1)
 Main PID: 13931 (mongod)
   CGroup: /system.slice/mongodb.service
           └─13931 /usr/bin/mongod --config /etc/mongodb.conf

Dec 16 12:25:28 dell-Vostro-15-3568 systemd[1]: Started An object/document-oriented database.
Dec 16 12:29:21 dell-Vostro-15-3568 systemd[1]: Started An object/document-oriented database.

Now check your MongoDB is installed successfully or not. so, simple check MongoDB version run by the following command.

mongod --version

After running this command you show something that look like the output in your terminal.

db version v2.6.10
2019-12-16T12:31:13.714+0530 git version: nogitversion
2019-12-16T12:31:13.714+0530 OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016

Conclusion

You can see Install the MongoDB in Ubuntu is very easy. You can check I hope you will like this article.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK