MongoDB v5.0.6 exited with status code 62

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.