Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

How to recover mongodb after unexpected shutdown?

There might be a situation when one cannot start the MongoDB due to unexpected shutdown or mongo server crashing. This is because of the mongod.lock file which is preventing to start mongoDb server.   Below are the steps to recover ...

"reason:errno:111 Connection refused OR exception:connect failed" on mongoDB restart in ubuntu 16.04

Fixed error "reason: error:111 Connection refused OR exception: connect failed" issue during mongoDB restart service in ubuntu 16.04 I got the problem like below during start the Mongo DB service after it's installation. Probl...

Creating database, collections and document in mongodb

In this blog we will learn about some terms and crud operations in mongodb. As we are very much aware about the terms related with RDBMS such as creating database, creating tables and insert records in the table. Here we will learn about the basi...

Redis server and its installation

Redis is the most popular key-value, open source and in-memory data structure store that can be used as a database. Here in-memory means that instead of storing the data on disk redis relies on main memory for data storage. As a result redis data...

What is NoSQL Database and its type

NoSQL is a non sql or we can say a non relational database management system. NoSQL is designed to support the requirements of cloud applications and to overcome issues like scalability, performance and data distribution limitations of relational...

Basic MongoDB Queries

1) Create a "testDB" database. use testDB 2) Create a collection name "users" and adding the value together using single command.   db.logins.insert({username:"neetu"}) or  First create a collecti...

MongoDB Installation steps for Ubuntu

MongoDB is a free and open source document  based DBMS . Use the following command for MongoDB installation: 1) Execute the following command to import the public GPG Key.    sudo apt-key adv --keyserver hkp://keyserver...

How To Import MongoDB Database on Ubuntu 14.04?

Importing Information Into MongoDB If you want to import information into MongoDB database, lets take an example to import the database of resturants. It's in json format and can be downloaded using wget:   wget https://raw.gi...

How To Export a MongoDB Database on Ubuntu 14.04?

Exporting Information From MongoDB   You can export MongoDB and acquire human readable text file. Data is exported in json format by default, but you can also export MongoDB in csv format. If you want to export data from MongoDB then y...

Cassandra: How To Install Cassandra on Ubuntu 14.04

About Cassandra: Cassandra/ Apache Cassandra is scalable NoSQL database system. It is used to manage large amount of structured, semi-structured and non structured data. I am writing this blog which will help you to install and run a single-node ...

MongoDB Connection With PHP

The MongoDB is built to work with your current web server, but not PHP. To communicate PHP with MongoDB server you need to install PHP-MongoDB driver. The PHP-MongoDB driver is a PHP extension library. The presently maintained driver for the Mong...

Data Modelling With MongoDB

Data in MongoDB contains a versatile schema. Documents that are in a same collection don't need to have an equivalent set of fields or structure, and common fields in an exceedingly collection's documents could hold differing kinds of dat...

MongoDB - Indexing

Indexes in MongoDB effective execution of query, Otherwise MongoDB must scan all documents inside of the collection to fetch document match the find statement. This scanning process is profoundly inefficient and require the MongoDB to handle a va...

MongoDB supported datatypes

Supported datatypes by MongoDB is given below: String: That is normally employed datatype for you to store the data. String inside mongodb have to be UTF-8 legitimate. Integer: This kind is utilized for you to store a new statistical worth....

Connecting to remote mongodb database via SSH

Hi friends, So many times developer face an issue of not able to connect to their mongo db using a GUI tool, If the mongo is installed on a remote server There is a solution of connecting to remotely installed mongodb via SSH First open your ...

How to update multiple array elements in mongodb

Hello Everyone, In this blog we will discuss about how to update multiple array elements in MongoDb using a single query. Let say we have a collection in MongoDb named "Form" which consists of the below available documents: > db.Form...

Does MongoDB's $in clause guarantee order?

Hello All, In this blog we will discuss whether MongoDB's $in clause guarantee order or not. The $in operator selects the documents where the value of a field equals any value in the specified array. To specify an $in expression, use the fo...

MongoDB Get names of all keys in collection

Hello All, In this blog we will discuss about how to get all keys in mongoDb collection. Sometimes we are in a situation in which we want only the keys not the data itself from the collection. So as a result you can try by following belo...

How to query mongodb with like?

Hello All, In this blog we will discuss about how to query mongodb with "like". In MySql you might have normally used below code to find by like select * from users where name like '%text%' But for using like in mongoDb you have t...

PHP Code to connect to MongoDB

To connect MongoDB with PHP you need to install MongoDB php driver. After you successful install MongoDB php driver, you need to create connection with MongoDB. MongoDB default port is 27017. To connect with localhost and default port $conn...

Retrieve only the queried element in an object array in MongoDB collection

Suppose we want retrieve only the queried element in an object array then we need to perform mongo query like below. Let me explain with this help of example. { _id: 4, zipcode: "63109", students: [ { name: "ankit", scho...

How do I perform the SQL Join equivalent in MongoDB

MongoDB does not have joins but sometimes we want references to documents in other collections. For this we have to use population. Population is the way of matching the specified paths in the document with document(s) from other collection(s)....

MongoDB Query Plan & Optimization

Indexes improve the efficiency of read operations by reducing the amount of data that query operations need to process. Create index for a collection : The index can be defined in schema of collection. Consider the following collection Accounts...

MongoDB Query Optimization using explain

The MongoDB query optimizer processes chooses the most efficient query plan form the available indexes. Then mongoDB query system use this index to execute and return the result. You can use the db.collection.explain() or the cursor.explain() ...

MongoDB Sharding explained

Sharding is a method for storing data into multiple distributed machines. Database systems with large data sets and high throughput applications can challenge the capacity of a single server. To prevent this MongoDB Sharding concept used. In S...

Two Phase commits in MongoDB

Hello All, In this we will discuss about how to perform two phase commit in MongoDB. Consider a example where funds will be transferred from one account to another. In a relation database approach we just subtract fund from account a and ad...

How to query mongodb with like

In MySql you have normally used below code to find by like select * from users where name like '%text%' But in order to use like in mongoDb you have write the below code:- You can use the actual regex object via MongoRegex db.collec...

Displaying Cursor Information in MongoDB

As we know cursor in mongoDB can be defined as return value of query run to mongoDB. The information of can be display using cursor.explain() function as show in below: db.collection.find().explain() The explain() method returns a documen...

Cursor In MongoDB

In mongo shell when find() query executed it return cursor with all document in the collection. However, if the returned cursor is not assigned to any variable then first 20 documents iterated automatically. In other word when a query run to m...

MongoDB : Javascript function

MongoDB - Javascript function $where operator : It uses to either a string containing a JavaScript expression. The full JavaScript function also used in the query system. This feature available after MongoDB version >= 2.4. List of prop...

MongoDB : $exist and $type operator

MongoDB - $exist and $type operator $type operator : It matches values based on their BSON type. e.g. We want to fetch documents from the collection which contains the value of "city" is only null. db.collection.find( { "city" : { $typ...

MongoDB : $in and $or operator

MongoDB - $in and $or operator $in operator : It match a value within the specified values within the given values. e.g. If we want to select record which credit score is (1200 and 2000). db.collection.find({"creditscore" :{$in :[1200,2...

MongoDB : Regex

MongoDB - Regular Expression In MongoDB if we need to find record with certain pattern, then we can use regular expression. It is also "like" query in SQL. e.g. If we want to find user email matching with "findnerd.com" pattern. db.colle...

MongoDB : Sorting

MongoDB - Sorting In any application we need to show list in certain order. Generally we show's user feeds in descending order. This can be achieve in MongoDB through "sort" properties. e.g. We need to sort student name in ascending order....

MongoDB : Limit and Skip

MongoDB - Limit with Skip Often we need to implement pagination in any application. We can use "limit" with "skip". "skip" will select record from given index. e.g. We need to find 10 record started form 10th index. db.collection.find()....

MongoDB : Skip

MongoDB - Skip Query Sometime we need to find out certain number of record after a certain number of record. e.g. We need to find out 10 record start after 10th index db.collection.find().skip(10).pretty(); It is equivalent in SQl: ...

MongoDB : Limit

MongoDB - Limit Query Sometime we need to find out certain number of record. In MongoDB we can achieve this through "limit" option. e.g. We need to find 10 record from any collection. db.collection.find().limit(10).pretty(); It is e...

Download mongoDB data as csv file

Want to export MongoDB collection data to a csv file use mongoexport utility that produces data in JSON or CSV format. Use the following command to export data: mongoexport --host <hostName> --db <databaseName> --collection <...

Restore Directly from a Snapshot

As explained on post how to archive a snapshot, Now to restore a backup without writing to a compressed gz file from created archive, use the following sequence of commands: umount /dev/vg0/snap_db-01 lvcreate --size 1G --name mdb-new vg0 dd...

Restore a Snapshot

As explained on post how to archive a snapshot, Now to restore a snapshot from created archive, use the following sequence of commands: lvcreate --size 1G --name mdb-new vg0 gzip -d -c snap_db-01.gz | dd of=/dev/vg0/mdb-new mount /dev/vg0/md...

Archive a Snapshot in MongoDB

To archive a snapshot first you need to create a mongoDB snapshot, The same is discussed on post Creating a mongDB snapshot with LVM. Now mount the created snapshot and copy this to separated storage volume. Or you can create a block level copy o...

Creating a mongDB snapshot with LVM

Snapshot can be represented by creating pointers (equivalent to hard links ) between special snapshot volume and live data. The snapshot process uses a copy-on-write strategy. As a result the snapshot only stores modified data. The primary pu...

Mongodb Error Could not connect to a primary node for replica

Could not connect to a primary node for replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:27017">] If you found above error then first check sudo service mongodb status If yes, then run following co...

How to solve [MongoError: connect ECONNREFUSED]

Hello Readers, I came across a solution while working on mongodb and would like to share with you all in case you face any such problem while working on mongodb. If you are coming across the error like the following: Connection error: {...

Getting database information in mongodb

Hello readers! Many time we get stuck with the query How to get the database information in Mongodb? Here below is the simple answer for this query- We can easily get the database information using below predefined methods: a) show dbs ...

Top MongoDB Commands

Small But Very Useful And Frequently Used Commond Step1: Remove lock file. sudo rm /var/lib/mongodb/mongod.lock sudo rm-rf mongodb/mongod.lock Step2: Repair mongodb. mongod --repair Step3: Start mongodb. sudo mongod -dbpath=mongo...

Creating ensure Index in Mogodb

Creating Indexes in Mogodb- ensure Index and get indexes then verify Hello readers! Many time we get stuck with the query How to Creating Indexes in Mogodb, ensure Index and get indexes then verify? Here below is the simple answer for this...

Document Data Model- MongoDB's

MongoDB is a document database that provides high performance, high availability, and easy scalability, since it is an unstructured data and doesn't require costly and time-consuming migrations when we want to change our schema dynamically . Mong...

Fetching data from Solr using Solarium

We seldom need to fetch result from solr based on limit and order by clause similar to sql queries , the same thing can be achieved using the below given code packet with solarium : // create a client instance $client = new Solarium\Client($...

How to make group by query in MongoDb

Making a group by query in traditional database like MySQL,MySQL etc in quite easy but when its come to NoSQL like MongoDb we have to twist it a bit to get result we want : There are two ways in which you can do group by in MongoDb : a) Usi...
prev 1
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: