• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Install and Configure the MongoDB on Linux Mint 20

  • 00:33 cat /etc/os-release
  • 00:44 wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
  • 00:51 echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
  • 00:58 apt update
  • 01:07 apt install mongodb -y
  • 01:30 systemctl start mongodb
  • 01:40 systemctl enable mongodb
  • 01:55 mongo
  • 02:08 db.createUser({user: "mongodadmin", pwd: "password", roles:[{role: "userAdminAnyDatabase" , db:"admin"}]})
  • 02:19 mongo -u mongodadmin -p --authenticationDatabase admin
  • 02:30 show dbs
  • 02:35 db.produxt.insert({item: "card", qty: 15})
  • 02:39 show collections
  • 02:45 db.product.insert({item: "card", qty: 15 })
  • 03:15 show collections
  • 03:22 db.produxt.drop()
  • 03:33 show collections
{{postValue.id}}

To Install and Configure the MongoDB on Linux Mint 20

Introduction:

MongoDB is a document-oriented DB that stores data in Jason like documents with a dynamic schema. It means you can store your records without worrying about the data structure such as the number of fields to store values. MongoDB documents are similar to JSON objects. This tutorial will cover the installation and configuration of the MongoDB on Linux Mint 20.

Installation Procedure:

Check the version of OS.

root@linuxhelp:~# cat /etc/os-release
NAME="Linux Mint"
VERSION="20 (Ulyana)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 20"
VERSION_ID="20"

Add the MongoDB repository by using the following command

root@linuxhelp:~# wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
ok

Create a list file for MongoDB

root@linuxhelp:~# echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse

Run the update command for update the repositary

root@linuxhelp:~# apt update
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Ign:2 http://packages.linuxmint.com ulyana InRelease
.
Reading package lists... Done
Building dependency tree
Reading state information... Done
399 packages can be upgraded. Run 'apt list --upgradable' to see them.

Now install MongoDB by using the following command

root@linuxhelp:~# apt install mongodb -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libboost-program-options1.71.0 libgoogle-perftools4 libpcrecpp0v5 libtcmalloc-minimal4 libyaml-cpp0.6 mongo-tools mongodb-clients mongodb-server mongodb-server-core
.
.
.
Setting up mongodb-server (1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5) ...
Created symlink /etc/systemd/system/multi-user.target.wants/mongodb.service → /lib/systemd/system/mongodb.service.
Setting up mongodb (1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
Processing triggers for systemd (245.4-4ubuntu3) ...

Once the installation is completed. Start the service of MongoDB

root@linuxhelp:~# systemctl start mongodb

Now enable the MongoDB service

root@linuxhelp:~# systemctl enable mongodb
Synchronizing state of mongodb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mongodb

Now enter into the MongoDB shell and create database and user for admin

root@linuxhelp:~# mongo
MongoDB shell version v3.6.8
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("7479068f-7ff6-440c-b440-12fd9fa1ca6e") }
MongoDB server version: 3.6.8
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
Server has startup warnings:
2020-12-09T15:55:40.401+0530 I STORAGE  [initandlisten]
2020-12-09T15:55:40.401+0530 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-12-09T15:55:40.401+0530 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-12-09T15:55:41.965+0530 I CONTROL  [initandlisten]
2020-12-09T15:55:41.965+0530 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-12-09T15:55:41.965+0530 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2020-12-09T15:55:41.965+0530 I CONTROL  [initandlisten]

Now switch to database

> use admin
switched to db admin
>
>
>
> db.createUser({user: "mongodadmin", pwd: "password", roles:[{role: "userAdminAnyDatabase" , db:"admin"}]})
Successfully added user: {
        "user" : "mongodadmin",
        "roles" : [
                {
                        "role" : "userAdminAnyDatabase",
                        "db" : "admin"
                }
        ]
}
>exit
Bye

Now login to MongoDB using admin credentials and configure the collection and drop collection

> mongo -u mongodadmin -p --authenticationDatabase admin
2020-12-09T15:57:11.007+0530 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:9
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB

Now create a collection by using the following command

> db.produxt.insert({item: "card", qty: 15})
WriteResult({ "nInserted" : 1 })

Now show the table by using the following command

> show collections
produxt
system.users
system.version
> db.product.insert({item: "card", qty: 15 })
WriteResult({ "nInserted" : 1 })
> show collections
product
produxt
system.users
system.version

Delete the existing table by using the following command

> db.produxt.drop()
true
> show collections
product
system.users
system.version
> exit
bye

With this method the installation and configuration of MongoDB on Linux Mint comes to an end.

Tags:
eldhapearline
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

Is mongodb .repo already exists on centos?

A

No, we need to create and add the configuration

Q

How to add a repo for MongoDB on Linuxmint?

A

The command is # wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -

Q

Does MongoDB support SQL?

A

No it does not support directly. However, MongoDB does support a rich query language of its own. For examples on using MongoDB’s query language, see MongoDB CRUD
Operations.

Q

What are MongoDB and its uses?

A

MongoDB is a document-oriented database that stores data in JSON-like documents with a dynamic schema. It means you can store your records without worrying about the data structure such as the number of fields or types of fields to store values. MongoDB documents are similar to JSON objects.

Q

What is MongoDB atlas?

A

MongoDB Atlas is a fully-managed cloud database developed by the same people that build MongoDB. Atlas handles all the complexity of deploying,
managing, and healing your deployments on the cloud service provider of your choice (AWS, Azure, and GCP). Follow the links below to get started.
Deploy your first free cluster.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ryan ?
how to use visual traceroute tool

Am using traceroute command to check for the route. i got this tool while surfing. So pls help me out installation and usage of Visual traceroute tool.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.