Lesson 1: Managing MongoDB Servers / Learn

Video Transcript (English)

mongod is the primary daemon process for the MongoDB system. It handles connections, requests, and most importantly, persisting your data.

A daemon is a computer program that runs as a background process. By convention, daemons have a “d” appended to their name, hence the name mongo d.

In this video, you will learn how to install MongoDB on Ubuntu Linux. Next, you will learn how to start, connect to, and stop a mongod service. You’ll also learn how to confirm that a mongod service is running.

First, let’s install MongoDB on Ubuntu Linux by using the `apt` package manager.

In the terminal, we’ll use this command to import the public key that’s used by the package management system.

Next, let’s create a list file for MongoDB.

Now, we’ll issue this command to reload the local package database.

Now we will install the latest stable version of MongoDB Community Edition.

Great! Now that we have installed MongoDB, let’s take a look at the default configuration options that are created by the package installer.

We’ll highlight two commonly changed options: bindIp and security.

bindIp defaults to localhost, but it can be updated to allow the MongoDB server to communicate with other hosts.

security is used to enable authorization. It ensures that only approved users can connect to your MongoDB server. We will leave authorization turned off for now so that we can showcase some of the features. However, we strongly recommend enabling authorization on all of your MongoDB deployments.

To clean things up, let’s clear the screen.

Now we’re ready to start the mongod service by using this command. The service will start the daemon process by using the default configuration file.

To confirm that the service is running, we use the command that you use to check running services on your machine.

We’ll use this command to check on our service. The output confirms that our service is running.

If you’re on a machine that doesn’t use Ubuntu Linux, this command and output may be different.

Now that we’ve confirmed that the service is running, let’s connect to MongoDB. Remember that we interact with mongod by using a client. In our case, we’ll use the MongoDB Shell, which is also called mongosh.

We’ll use mongosh to connect to the server by using localhost and the default port.

Alright, we're connected. Now let's run the command `show dbs` from the shell to get a list of databases. The output here lists the admin, config, and local databases.

If you've been using MongoDB already, you may see additional databases listed.

We're done with mongod for now, so let's exit the MongoDB Shell by using the `exit` command.

Finally, we’ll shut down the service by using `systemctl`.

To confirm that the service was successfully shut down, we’ll run this command in the terminal again.

The output shows that the status is inactive, which confirms that we’ve successfully shut down the service.

Nice work! Let’s recap what you learned in this video:

mongod is the primary daemon process for a MongoDB deployment. It handles connections, requests, and persisting your data.

We went through the steps for installing MongoDB on Ubuntu Linux.

If you’re not using Ubuntu Linux, visit MongoDB’s documentation for more installation guides.

After installing MongoDB, we started a mongod service, checked the status of the service, and connected to the service by using the MongoDB Shell.

Finally, you learned how to stop the mongod service.