#Install mongo shell only on ubuntu install#
It won't show the warning message about Access Control as we saw in Fig 1. Mongo -u admin -p -authenticationDatabase admin Now we can connect with MongoDB using the shell as shown below. Now save the file and reload the settings using the command as shown below. Sudo nano /lib/systemd/system/rviceĮxecStart=/usr/bin/mongod -auth -config /etc/nf We can further tighten the security by enabling the MongoDB authentication using the commands as shown below. We can start creating the databases and add data either using the shell or programmatically using the preferred language. This is how we can add admin users to the admin database and assign a role to the user. Now we will add the user admin with root role to the admin database using the commands as shown below.ĭb.createUser( We can see that MongoDB has already created three databases i.e. The RBAC provided by MongoDB governs access to a MongoDB system. The same user having appropriate permissions can act on multiple databases using the Role-Based Access Control (RBAC). MongoDB provides options to create the Authentication Database to store user details and privileges across different databases. It shows the warning message indicating that the RBAC is not enabled. Start the MongoDB Shell as shown in Fig 1.
The default behavior is to start the server as part of the installation process. We can also enable or disable the MongoDB server to start automatically with the server. We can start and stop the server as system service using the commands as shown below. This confirms that we have successfully installed the MongoDB server. In this step, we will verify the installation using the commands as shown below. # Keep the current version installed on system upgradeĮcho "mongodb-org hold" | sudo dpkg -set-selectionsĮcho "mongodb-org-server hold" | sudo dpkg -set-selectionsĮcho "mongodb-org-shell hold" | sudo dpkg -set-selectionsĮcho "mongodb-org-mongos hold" | sudo dpkg -set-selectionsĮcho "mongodb-org-tools hold" | sudo dpkg -set-selections We can optionally avoid the auto-upgrade of the currently installed MongoDB packages using the commands as shown below. The command also starts the MongoDB database service.
We can see that the above command installed the packages mongodb-org, mongodb-org-server, mongodb-org- mongos, mongodb-org-shell, and mongodb-org-tools. Processing triggers for man-db (2.8.3-2ubuntu0.1). Now install the latest MongoDB server using the command as shown below. Now refresh the packages index using the command as shown below. You can also create the file directly as shown below.Įcho "deb bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt//mongodb-org-4.2.list # Copy and paste the content to the list fileĭeb bionic/mongodb-org/4.2 multiverse The above command will show the OK message after adding the Key.Ĭreate the list file for Ubuntu 18.04 LTS using the command as shown below. In this step, we will import the MongoDB public GPG Key using the command as shown below. We can also clean the files of the previous installation using the commands as shown below. You can use the below mentioned commands to remove the MongoDB installed on the desktop version using the installer downloaded from the official website. # Completely remove previous installation We can check the previous installation and remove it in case it's already installed on the system using the commands as shown below. 4.2 and onwards provides packages only for the Ubuntu 16.04 LTS and Ubuntu 18.04 LTS 64-bit version. You can also follow the Ubuntu Desktop Tutorial published by Tutorials24x7 to install MongoDB on the desktop version for development purposes.Īt the time of writing this tutorial, the most recent version of MongoDB i.e. It uses a package manager to install the latest MongoDB 4.2 Community Edition on Ubuntu 18.04 LTS. This tutorial provides the steps required to install MongoDB on the server version of Ubuntu. The steps should be the same for other versions of MongoDB including MongoDB 3 and Linux systems. This tutorial provides all the steps required to install and setup the MongoDB 4 Community Server on Ubuntu 18.04 LTS. MongoDB is a document-oriented, open-source and platform-independent Database Management System (DBMS). MongoDB is the most popular NoSQL database server and it can be used to store JSON documents.