MongoDB v5.0.6 exited with status code 62

Hi, I recently upgraded :

  • mongodb-org
  • mongodb-org-server
  • mongodb-org-shell
  • mongodb-org-mongos
  • mongodb-org-tools

from v4.2.9 to v5.0.6 in Ubuntu Desktop 20.04.3.


However, now I can not start mongod as it failed after being started using sudo systemctl start mongod.

Here is the log :

systemctl status mongod
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-03-03 07:54:19; 2min 37s ago
       Docs: https://docs.mongodb.org/manual
    Process: 1452 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=62)
   Main PID: 1452 (code=exited, status=62)

Mar 03 09:54:17 ubuntu systemd[1]: Started MongoDB Database Server.
Mar 03 09:54:19 ubuntu systemd[1]: mongod.service: Main process exited, code=exited, status=62/n/a
Mar 03 09:54:19 ubuntu systemd[1]: mongod.service: Failed with result 'exit-code'.

It is said that status code 62 means : Returned by mongod if the datafiles in --dbpath are incompatible with the version of mongod currently running.

Is MongoDB v5.0.6 incompatible with Ubuntu Desktop 20.04.3 ?
How can I fix and start mongod normally ?

Sorry, let me correct thus line :

Active: failed (Result: exit-code) since Thu 2022-03-03 09:54:19; 2min 37s ago

Hi @marc,

Skipping over major release versions for an in-place upgrade (i.e. using the same data files) is currently not supported. Any required changes to data files are performed as part of each major version upgrade.

If you want to perform an in-place upgrade from MongoDB 4.2 to MongoDB 5.0 you need to:

Per the MongoDB Production Notes, Ubuntu 20.04 is currently supported for MongoDB 4.4 and 5.0. Ubuntu 20.04 is a Long Term Support (LTS) Ubuntu release, so it won’t reach End-of-Life until April, 2025.

Regards,
Stennie

1 Like

Status Code 62 suggests that the data directory defined in the /etc/mongod.conf file under the key storage->dbPath is not compatible with this version. In case you don’t need to keep the backup of your database, you can just erase the path specified in /etc/mongod.conf and then uninstall and reinstall the mongodb.

So the steps are:

  1. sudo rm -rf /var/lib/mongodb ( considering /var/lib/mongodb is your data location )
  2. sudo apt purge mongodb-org*
  3. sudo apt install -y mongodb-org

In case you need to keep backup of your data, please make sure to copy data directory first.