I followed the MongoDB Docs to run my MongoDB in macOS,
When I start MongoDB using the terminal get this error:
Shutting down with code: 62
I followed the MongoDB Docs to run my MongoDB in macOS,
When I start MongoDB using the terminal get this error:
Shutting down with code: 62
Delete the data directory where MongoDB stored and create again.
rmdir data
And:
mkdir data/db
I had a similar problem when I switched to a new version mongod
without upgrading the data (from version 3.2
, for example, to version 3.6
).
In this case, mongod
outputs ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.
(mongod
was started with the --verbose
key).
The link does lead to detailed instructions on how to upgrade the data.
It is strange that error 62
is not described in the documentation.
This has worked for me
Initially i was facing various issues, like when i tried to start the server by using:
mongod
I received this error: shutting down with code 100
and then i tried to start by
sudo mongod
I received this error: shutting down with code 62
finally this command helped me to get rid of various issues
sudo mongod --repair
Now mongod server is running tentatively
sudo mongod
Error code 62:MongoDB dbpath doesn't support the current version
Removing data director is not an optimal
solution. The best solution would be to upgrade to the higher version.
Else take the dump & restore the complete database on a fresh instance with a higher version.
mongodump --db employee --out /path/
mongorestore /path/employee/
Hope this helps !!!
I ran into this issue on Arch Linux. I solved it by installing mongodb34-bin from the AUR (which required removing the mongodb package). Then I ran
$ sudo mongodb --repair
Then, I started the database from the 3.4 binary, and ran
$ mongo
> db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
{ "ok" : 1 }
> quit
After that, I stopped the 3.4 version, and reinstalled the regular mongodb package, and did a second repair.
Please ensure if you are upgrading MongoDB, your featureCompatibilityVersion version is correct. I faced similar problem, after updating featureCompatibilityVersion to the correct version, it worked fine.
Reference: https://docs.mongodb.com/manual/reference/command/setFeatureCompatibilityVersion/
In most cases, this error seems to come due to skipping one or more versions when upgrading MongoDB. The proper solution (i.e., no data loss) is to go through the versions one at a time.
For each version, make sure to run the mongo
shell for that version, and run the following command:
db.adminCommand({setFeatureCompatibilityVersion:"<major.minor>"})
...where <major.minor>
is replaced with the major and minor version of MongoDB. For example, version 4.4.9 would become 4.4
, and version 5.0.2 would become 5.0
.
Eventually the new version of MongoDB that you are trying to run should succeed.
NOTE: if you step through the versions without the admin command, it probably won't work.
You can change back the binaries to Mongodb 3.4.2.3 to follow: Download tar from mongodb website as per your destribution from : https://www.mongodb.org/downloads Untar downloaded file.
tar -zxvf {mongo-tar-file}.tgz
Stop mongod service.
sudo service mongod stop
Replace binaries from your tar/bin to /usr/bin.
cd {your-extracted-folder}/bin
sudo mv -f * /usr/bin/
Start mongod service.
sudo service mongod start
and then when mongo running
again do: db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
Then you can update to 3.6
Answers of others are correct but not work for me and i fix this problem like this:
sudo apt-get purge mongo*
Or you can use:
sudo apt remove mongo*
After that:
sudo apt-get purge mongodb-org*
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
and:
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc \
sudo apt-key add -
then:
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" \
sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
after that:
sudo apt-get install -y mongodb-org=4.2.0 \
mongodb-org-server=4.2.0 \
mongodb-org-shell=4.2.0 \
mongodb-org-mongos=4.2.0 \
mongodb-org-tools=4.2.0
Finally:
systemctl enable mongod.service
sudo service mongod start
My errror started with an error 62.
2018-06-10T13:49:27.750-0400 I CONTROL [initandlisten] shutting down with code:62
I deleted /db and reinstalled /db in /data/db.
$ sudo -r rm db
Once I did this and tried to run >mongod I got a 100 error. I had to change the rights
2018-06-10T13:52:20.042-0400 I CONTROL [initandlisten] shutting down with code:100
To fix this I did:
$ sudo chown -R `id -un` /data/db
Once this was run I was able to run mongo db.
$mongod
I hope this helps.
Although the accepted answer works, it removes all your data.
What worked for me without need to lose my DB is using mongodump
to create a backup of the data. Then removing it by sudo rm -r /path/to/dbdata
and finally restoring it with mongorestore
.
That made systemctl start mongodb
to not fail and the data was in perfect state.