Skip to main content

Installing Mongo database on Linux



I was trying to learn basics of using Mongo database recently. I am capturing some of the things I learnt below so it will be helpful for other people.

Installing Mongo database on Linux:

First lets intall Mongo db. I use a Ubuntu OS laptop. Below are steps to follow to install Mongo -
  • In Linux, it is better to use the package manager to install software. In Ubuntu, we can use the apt commands to install mongo
  • To ensure authenticity of the package that needs to be installed, Ubuntu requires packages be signed with GPG keys. As a first step, let us download the key from ubuntu.com.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 

 
  • Next we will need to add the repository for mongo in the list of sources for your ubuntu laptop. I will do that by creating a list file for mongo -
 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list


  • Next keep the ubuntu package database updated
 sudo apt-get update
  • now lets install mongo. Install the latest version always unless you have a specific reason to use an older version
 sudo apt-get install -y mongodb-org





  • Now this installs mongodb in your Ubuntu. To start Mongo services, in a terminal window, type - mongod . This will start mongo services with port 27017
  • To log into mongo shell and query the database, in another terminal type - mongo
Now, lets look at some useful commands to know while working with a mongo database -
  •  show dbs
this shows all available databases present
  • use <db name>
 this switches to the appropriate database you specified
  • show collections
this command shows all collections in the database
  • db.<collection>.find()
this command shows all documents within the collection you specified.

  • db.<collection>.insert({"test":"123"})
this command inserts a document into the collection with the json data i specified.
There are many more commands to learn -  db.<collection>.update, etc

At least hopefully this will get you started. Enjoy!

Comments

Popular posts from this blog

Workaround to bypass Salesforce SSO

One of the best practices for implementing Single Sign On for your Salesforce org is always ensure there is a way your System administrator can login via the standard login page side-stepping the SSO configuration.  Reason for this is if ever something goes wrong with your Idp provider's service and the SSO authentication responses are not coming as expected, all your users are unable to login. That is, if you have setup your My domain to prevent logins via standard Salesforce login urls (login.salesforce.com). This includes the System administrator as well. Only if your system administrator can somehow login, then he or she can disable the SSO settings for your domain and allow login via the normal login page as a temporary measure. What do you do in such a situation? Well Salesforce has built a workaround for this which is not well documented anywhere (probably for a good reason :) ). I found out about it from a colleague at work. If your my domain url is - https://Com...

DBAmp for Salesforce - salesforce integration for SQL Server DBAs

Recently i got the opportunity to explore a tool called DBAmp for integration with Salesforce. I found it to be a very useful tool which will help with any data manipulation requirements in Salesforce. Following are my learnings from the exercise. Hope it helps any of you who may need to work with this tool -  DBAmp is a SQL Server package that can be used to integrate with Salesforce. The site where this software is available is - http://www.forceamp.com/ Overview: It essentially installs on top of an existing SQL Server database and provides an OLE DB connector that can be used to connect to Salesforce. Behind the scenes, it executes API calls against Salesforce for any SQL server command it receives. Thus we can create a connection in SQL server to Salesforce org and pull data into tables in the database just as if we are querying against Salesforce tables directly. Use cases for DBAmap + Salesforce: Many use cases exist for using this tool against Sales...

Summer 16 Salesforce Administrator Maintenance exams

I was able to clear my Summer 16 Salesforce administrator maintence exam earlier today. Next I need to start working on Winter 17 immediately. Anyway before that i thought i will leave some pointers to any folks who may be taking Summer 16 anytime soon Below are some topics you can read about to prepare yourself for the exam - 1. Process builder improvements -  Process builder can now execute immediate actions and then evaluate the next criteria in the flow. Please see this link - https://releasenotes.docs.salesforce.com/en-us/summer16/release-notes/rn_forcecom_process_multiple_actions.htm Expect a question on this. 2. Files sharing permission -  In Classic, when a file is shared to a user via a record, its access can be set to "Set by Record". This allows the record level access to determine access level for the file as well. Read about this below - https://releasenotes.docs.salesforce.com/en-us/summer16/release-notes/rn_files_access_by_record.htm 3. Chatter Q...