News
Seven days of Black Friday madness — great deal from Serverspace!
Serverspace Black Friday
RF
December 25, 2023
Updated December 27, 2023

How to update MongoDB?

Databases MongoDB

Overview

That instruction dedicated updating process of the MongoDB when you have trouble with current version, exist needs to installation compatible version, commonly update software or any else reason. We consider several ways, which help to update system software and freeze version of using software!

Installation

For avoid problem with library package and older utility we have to update system packages through apt manager:

apt update && apt upgrade -y
Update
Screenshot №1 — Update

After process was finished without problem, we can check installed version of the DBMS for make next step more clearness:

apt list | grep "mongodb-org*" | grep "installed"
Grep
Screenshot №2 — Grep

In the display you can see version at the right side of the package name, on the official site we can choose  any else version of package and remember numerical record.

Also don't forget to backup all your database, we consider way to save DB for community edition take it in mind!

mongodump --host 127.0.0.1 --port 27017 --username <user> --password <pass> --db <database_name> --out <backup_catalog>

That command help to save indicated DB for dedicated user in the current directory where user was actived!

Now we consider way installation through purge, type in the CLI command below:

apt purge mongodb-org*
Purge
Screenshot №3 — Purge

The purge option delete all dependencies of the package and record mongodb-org with sign * at the end indicate all bounded package with that. On the system stay only log and library, we can delete them by the command:

rm -rf /var/log/mongodb
rm -rf /var/lib/mongodb

After that we can indicate needed version of the installation package, in that case you need to specify all entity, because of in another way only indicated version on the package will be updated:

apt install  mongodb-org=7.0.0 -y
Version
Screenshot №4 — Version

For avoid problem with accidental update package on the newer version when you want to save yours, use command below:

echo "mongodb-org-tools hold" | dpkg --set-selections

That action you need to do with every installed package! And that's it, we are update our packages! If you have troubles with starting daemon, than try to make sure that work correctly with systemctl:

systemctl status mongod
Status
Screenshot №5 — Status

Than if you see dead process start it, by the command:

systemctl start mongod

That can help to troubleshoot your issue with daemon and start unloaded service.

The updating process for MongoDB becomes essential in scenarios where issues arise with the current version, necessitating the installation of a compatible version, routine software updates, or other reasons.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.