How to Remote Login to MongoDB using terminal Ubuntu 18.04/20.04 LTS - TechBeginner

Welcome to TechBeginner.in, Tech Beginner provides technical blog for Online Linux Tutorials, Ubuntu Tutorials, Redhat Tutorials and CentOS 7, Configuration of server like Web Server, Application server, Database server, Window server, networking, html, css, java script, php, wordpress, opencart, magento, joomla and etc.

How to Remote Login to MongoDB using terminal Ubuntu 18.04/20.04 LTS

Share This

 



Whenever we secure the MongoDB server, So then we need to configure port number, username, password and so on and after configuration all of things, We need to connect MongoDB Shell by using different command. 


In this post, We will take MongoDB remote login with different different method. 

 

Method 1: Shell Access using Credentials

 

In this command we are going to use username, password, IP Address and Database by following the given command.

mongo -u username_here -p password_here IP_address_here/database_name_here

 

Example:-

 

In my case i am using below credentials.

 

MongoDB Server IP - 192.168.0.10

MongoDB Port - 27017

Username - admin

Password  - password


My MongoDB command would be like this.


mongo -u admin -p password 192.168.0.10/admin


Same command can we use for localhost like this.



Method 2: Shell Access using Credentials with Port Number


In this command, We are going to use port number by default MongoDB default port number is 27017, You need to replace it if you are have configured with another one, Use the following command for the same. 


mongo -u user_name_here -p password_here localhost:27017/database_name_here


Example:-

 

In my case i am using below credentials.

 

MongoDB Server IP - 192.168.0.10

MongoDB Port - 27017

Username - admin

Password  - password


My MongoDB command would be like this.

mongo -u admin -p password 192.168.0.10:27017/admin  

No comments:

Post a Comment