Upgrading mongodb has no effect and still shows the old version
I'm in the exact same situation, followed the exact same steps, and had the same issue.
What worked for me was:
sudo service mongod stopsudo apt-get purge mongodb-org*
Do NOT remove data directories - all your data will be lost if doing so.
Note: Calling sudo apt-get purge mongodb-org*
deletes the mongod.conf
file. In case you want to keep this file after the update, make sure you create a backup copy of it and use it after the new version has been installed.
Then install mongodb with:
sudo apt-get install -y mongodb-org
This assumes that you've already performed the previous installation steps (importing the public key, creating a list file, reloading local package database) as you've stated.
[Disclaimer] Before going into upgrade consider that moving from 2.6 to 3.+ requires an update on storage files. Same if you are updating from 3.2 to 3.4 or 3.4 to 3.6. Important: You can't directly upgrade from 3.2 to 3.6, for example. You must upgrade "step by step" 3.2-->3.4-->3.6. See this question/answer for details.
This is necessary if you want to recover your old DBs
As of writing 3.6 is the latest version of MongoDB. Some details here
Beware that changing between versions also regards some syntax in .conf file.
[Procedure] A more general framework for updating is to follow the typical procedure as shown here, but point to "Install a specific release of MongoDB" part of this guide as you already have MongoDB installed.
An example on Ubuntu 14.04:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.listsudo apt-get updatesudo apt-get install -y mongodb-org=3.2.18 mongodb-org-server=3.2.18 mongodb-org-shell=3.2.18 mongodb-org-mongos=3.2.18 mongodb-org-tools=3.2.18