40

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

enter image description here

Hastalavistababyml
  • 1,078
  • 1
  • 9
  • 15
  • 4
    I got the same error running mongodb in docker on an ec2 instance. Fixed it by deleting the data directory where mongodb stored its metadata and documents. For me it was located at /data/db – mrlarssen Dec 18 '17 at 19:22
  • 1
    it worked for me too. Thanks. – Hastalavistababyml Dec 18 '17 at 22:50
  • 2
    As a side note to future viewers of this question: You may have gotten this error after updating MongoDB. If so you should look at upgrading your previously stored information if you're worried about losing it. – BRogers Mar 23 '18 at 01:02

12 Answers12

43

Delete the data directory where MongoDB stored and create again.

rmdir data

And:

mkdir data/db
Hastalavistababyml
  • 1,078
  • 1
  • 9
  • 15
10

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.

Chad von Nau
  • 4,316
  • 1
  • 23
  • 34
ZolotovPavel
  • 138
  • 6
  • 7
    The short version of how to go from 3.2 to 3.6 is to install 3.4 first, then run `db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )`. After that I could upgrade to 3.6 successfully. – Chad von Nau Feb 14 '18 at 01:10
  • 1
    Now the exit code `62` appeared in the [documentation](https://docs.mongodb.com/manual/reference/exit-codes/). – ZolotovPavel Feb 28 '18 at 14:51
  • @ChadvonNau after upgrading did you face any issues in the 3.6 version? – Jerry Apr 24 '18 at 04:34
  • 1
    @Jerry No, I did not. I only have one small database for a http://keystonejs.com app, so I can't speak for anything beyond that. – Chad von Nau Apr 25 '18 at 13:30
9

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
Akash Jain
  • 483
  • 5
  • 5
  • This worked for me, too. I had to use the right mongo version for the database, and then `--repair`. After that, everything worked correctly. – muammar Dec 20 '18 at 18:19
5
 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 !!!

Jerry
  • 7,863
  • 2
  • 26
  • 35
4

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.

ImNtReal
  • 41
  • 5
3

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/

2

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.

1

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

Vacak7
  • 11
  • 2
1

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
akbar
  • 625
  • 6
  • 12
0

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.

Jesse
  • 213
  • 3
  • 13
0

In your directory C:, you may see the folder "data", and do:

mkdir -p data\db

in your command prompt in that location.

Partho63
  • 3,117
  • 2
  • 21
  • 39
-1

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.