Mongo Db Install

If you only install mongodb-org=4.0.3 and do not include the component packages, the latest version of each MongoDB package will be installed regardless of what version you specified. Although you can specify any available version of MongoDB, apt-get will upgrade the packages when a newer version becomes available.

  1. Ubuntu Mongo Db Install
  2. Mongo Db Install
  3. Mongodb Installation
  4. Mongo Db Install Centos
  5. Mongo Db Install For Windows
  6. Mongodb Install Npm
  7. Configure Mongodb
Active7 months ago

I need to uninstall mongodb completely from my system (Ubuntu 11.10) and install version 2.0.5.

Currently, when I run:

I get the following error:

MongoDB shell version: 2.0.1
connecting to: db
Wed Jun 6 13:05:03 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84 exception: connect failed

David Edwards
4,2713 gold badges25 silver badges43 bronze badges
jyothijyothi

Ubuntu Mongo Db Install

3 Answers

There are two sets of packages for MongoDB; the standard Ubuntu packages, and a set published by 10gen themselves. The standard packages are out of date, especially for older releases of Ubuntu, so it is probably a good idea to set yourself up to install from the 10gen repositories.

The error message you quote suggests that you might have already tried this, since version 2.0.1 is not a standard Ubuntu package. I suggest that first of all, you completely uninstall Mongo and clean up your system. If you have existing data that you want to keep, you could take a backup of it. By default, it is stored in /var/lib/mongodb. So if you want to take a backup, take a copy of the files from there and keep them in a safe place.

Uninstalling existing MongoDB packages

Since I'm not 100% what you've got installed, I suggest the following to make sure everything is uninstalled:

Some of those commands may fail, depending on what packages you actually have installed, but that's okay.

This should also remove your config from /etc/mongodb.conf. If you want to completely clean up, you might also want to remove the data directory /var/lib/mongodb, so long as you backed it up or don't want it any more.

If you've installed by building from source or using the 10gen binary distributions, then you'll need to manually uninstall and clean up from wherever you put the binary files, config and data files.

Installing the 10gen MongoDB packages

Follow the 10gen instructions for adding their repository:

Edit /etc/apt/sources.list, delete any lines you have already added for Mongo, and add the following single line (since 11.10 uses upstart) at the end:

Note that if you add this repository using the Software Center, it will automatically add a deb-src entry, which will break apt-get. So you will need to edit your sources list by hand to add only the above line.

Then to install, run:

Checking your install

Installing the packages should automatically start up the MongoDB server. So you should be able to run the client from the command line:

which should successfully connect to the test database. You can quit by typing exit.

If that fails, please update your question with further details, including the output of trying to connect and attaching your /var/log/mongodb/mongodb.log file.

David EdwardsDavid EdwardsInstall
4,2713 gold badges25 silver badges43 bronze badges

To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.

  1. Stop MongoDB

    Stop the mongod process by issuing the following command:

  2. Remove Packages

    Remove any MongoDB packages that you had previously installed.

  3. Remove Data Directories.

    Remove MongoDB databases and log files.

David Foerster
29.2k13 gold badges68 silver badges115 bronze badges
BhaveshBhavesh

Follow the steps:

  1. Remove lock file

  2. Repair mongodb

  3. Start mongodb

  4. Start mongo console

Aditya
9,71312 gold badges56 silver badges89 bronze badges
user2123184user2123184

protected by CommunityFeb 7 at 6:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged 11.10mongodb or ask your own question.

In this quick post, we will see how we can install one of the most popular NoSQL database, MongoDB on Ubuntu and start using it as well. We will get started now.

MongoDB Database

MongoDB is one of the most popular NoSQL databases which is used to store and query schemaless data.

Today’s data has undefined number of properties. New properties of an object are added everyday and those properties might not be present in all the Objects which currently exist. MySQL databases store these properties even for Objects which doesn’t have them. Let’s see an example:

NameAddress Line 1Address Line 2Address Line 3
JohnA-1717th StreetFlorida
SamB-46California

Mongo Db Install

If we had saved this data in a NoSQL database, it would have looked like:

[
{
'name':'John',
'address_line1':'A-17',
'address_line2':'17th Street',
'address_line3':'Florida'
},
{
'name':'John',
'address_line1':'B-46',
'address_line2':'California'
}
]

See the difference, the field which is not applicable for an object is not even present as a column.

Installing MongoDB

Now, installing MongoDB is just a matter of few commands. To start, let’s allow Ubuntu to ensure the authenticity of the software we are trying to install:

sudoapt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv EA312927

Once we run this command, we will get following output:

Ubuntu imported the MongoDB key into its package manager. Next, run the next command to create a list file for MongoDB:

echo'deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse'
|sudotee/etc/apt/sources.list.d/mongodb-org-3.2.list

Once we run this command, we will get following output:

Let’s finally update the package list:

Now, we are ready to install MongoDB now:

Once you run this command, it might take a few minutes to install MongoDB packages.
Now, run these two commands to start the MongoDB service and check its status:

sudo systemctl start mongod
sudo systemctl status mongod

Once we run this command, we will get following output:

Mongodb Installation

We will also enable MongoDB to start automatically when the system starts:

Mongo Db Install Centos

Once we run this command, we will get following output:

Queries with mongoDB

Now that we have installed and started MongoDB, we can also query data using it. Let’s try some sample commands here.

Using Mongo Shell

To start running MongoDB queries, we can open Mongo shell by just typing:

Shell will open:

Inserting Data

Mongo Db Install For Windows

Now, we can make a new database:

And we can insert data into it:

Note that we didn’t have to make the platforms collection and it was made automatically.

Getting Data

We can run a simple command to get the data we saved:

Mongodb Install Npm

In the second query above, we also printed the number of documents present in the collection.

Further Study

Configure Mongodb

In this quick post, we learned how we can install MongoDB and run basic queries on it. To go deeper into MongoDB check out these excellent resources below:

  • MongoDB: The Definitive Guide: Powerful and Scalable Data Storage
  • MongoDB in Action: Covers MongoDB version 3.0
  • Mastering MongoDB 3.x: An expert’s guide to building fault-tolerant MongoDB applications