How To Install And Configure MongoDB On Linux Mint 20.2
To Install And Configure MongoDB On Linux Mint 20.2
Introduction:
MongoDB is an open-source database management system for NoSQL databases. The NoSQL database system is used as an alternative to relational databases. NoSQL databases are quite useful for working with large amounts of data distributed over the internet. Using MongoDB, you can store and retrieve document-oriented information.
Installation Procedure :
Step 1 : Check the OS version by using the below command
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20.2
Release: 20.2
Codename: uma
Step 2 : Add the MongoDB Repository by using the below command
root@linuxhelp:~# wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add - OK
Step 3 : Create the List File for MongoDB by using the below command
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
Step 4 : Update the Repositories by using the below command
root@linuxhelp:~# apt update
Hit:1 http://repo.mysql.com/apt/ubuntu focal InRelease
Ign:2 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 InRelease
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Get:6 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 Release [3,951 B]
Ign:7 http://packages.linuxmint.com uma InRelease
Hit:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:9 http://archive.canonical.com/ubuntu focal InRelease
Get:10 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 Release.gpg [801 B]
Hit:11 http://packages.linuxmint.com uma Release
Get:12 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 Packages [15.3 kB]
Fetched 20.0 kB in 3s (6,433 B/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
28 packages can be upgraded. Run 'apt list --upgradable' to see them.
Step 5 : Install the MongoDB by using the below 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 libtcmalloc-minimal4 libyaml-cpp0.6 mongo-tools mongodb-clients
mongodb-server mongodb-server-core
The following NEW packages will be installed:
libboost-program-options1.71.0 libgoogle-perftools4 libtcmalloc-minimal4 libyaml-cpp0.6 mongo-tools mongodb mongodb-clients
mongodb-server mongodb-server-core
0 upgraded, 9 newly installed, 0 to remove and 28 not upgraded.
Need to get 56.3 MB of archives.
After this operation, 229 MB of additional disk space will be used.
Selecting previously unselected package mongodb.
Setting up mongodb (1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for systemd (245.4-4ubuntu3.13) ...
Step 6 : Start the service of MongoDB by using the below command
root@linuxhelp:~# systemctl start mongodb
Step 7 : enabling the service Of MongoDB
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
Step 8 : Enter Into the MongoDB Shell by using the below command
root@linuxhelp:~# mongo
MongoDB shell version v3.6.8
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("527d17ac-13cf-487e-9f6a-2b7d7065391d") }
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:
2021-12-31T01:30:09.044+0530 I STORAGE [initandlisten]
2021-12-31T01:30:09.045+0530 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2021-12-31T01:30:09.045+0530 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-12-31T01:30:10.130+0530 I CONTROL [initandlisten]
2021-12-31T01:30:10.130+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2021-12-31T01:30:10.130+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2021-12-31T01:30:10.130+0530 I CONTROL [initandlisten]
Step 9 : Switch to db Admin by using the below command
> use admin
switched to db admin
Step 10 : Create the user and password Credentials for Admin login by using the below command
> db.createUser({user: "mongodadmin", pwd: "password", roles:[{role: "userAdminAnyDatabase" , db:"admin"}]})
Successfully added user: {
"user" : "mongodadmin",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
]
}
Step 11 : Exit from the shell
> exit
bye
Step 12 : Login to the MongoDB Using Admin Credentials by using the below command
root@linuxhelp:~# mongo -u mongodadmin -p --authenticationDatabase admin
MongoDB shell version v3.6.8
Enter password:
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("906de26b-8293-4de4-bd47-5c11d7abc6d8") }
MongoDB server version: 3.6.8
Server has startup warnings:
2021-12-31T01:30:09.045+0530 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2021-12-31T01:30:09.045+0530 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-12-31T01:30:10.130+0530 I CONTROL [initandlisten]
2021-12-31T01:30:10.130+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2021-12-31T01:30:10.130+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2021-12-31T01:30:10.130+0530 I CONTROL [initandlisten]
Step 13 : List the Database by using the below command
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
Step 14 : Create the new collection by using the below command
> db.produxt.insert({item: "bottel", qty: 25})
WriteResult({ "nInserted" : 1 })
Step 15 : List the collection by using the below command
> show collections
produxt
Step 16 : Create the Second collection by using the below command
> db.product.insert({item:"bottel" , qty:25})
WriteResult({ "nInserted" : 1 })
Step 17 : List the Collection by using the below command
> show collections
product
produxt
Step 18 : Drop the Collection by using the below command
> db.produxt.drop()
True
Step 19 : List the Collection which is dropped or not by using the below command
> show collections
product
Step 20 : Exit From the Shell using the below command
> exit
Bye
With this the process of Installing the MongoDB On Linux Mint 20.2 has Come to an End…!!