mongodump --db simplysmart_api_development --out /home/rohit/Desktop/dump
cd Desktop/softwares
mongod --dbpath='/home/rohit/Desktop/softwares/simplysmart_api_development'
mongorestore -d 'simplysmart_api_development' '/home/rohit/Desktop/softwares/simplysmart_api_development'
Check if you are able to access db records in rails console.
Uninstall version 3.2:
sudo service mongod stop
sudo apt-get purge mongodb-org*
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
NOTE: To upgrade from a version earlier than the 3.6-series, you must successively upgrade major releases until you have upgraded to 3.6-series. For example, if you are running a 3.4-series, you must upgrade first to 3.6 before you can upgrade to 4.0. It holds true for all versions.
Upgrade to version 3.4: Follow instructions on the following install link. If you have 3.2 installed, it will get upgraded
https://docs.mongodb.com/v3.4/tutorial/install-mongodb-on-ubuntu/
Follow step 1
https://docs.mongodb.com/manual/release-notes/3.4-upgrade-standalone/ for reference
Upgrade to version 3.6:
https://docs.mongodb.com/v3.6/tutorial/install-mongodb-on-ubuntu/
Use the command that say install specific version of mongodb, it will upgrade mongodb from 3.4 to 3.6
Repeat step 1
This link helped me configure my mongodb https://hevodata.com/blog/install-mongodb-on-ubuntu/ to use start and stop CLI
Upgrade to 4.0:
Follow instructions on the following install link. It will get upgraded
https://docs.mongodb.com/v4.0/installation
https://docs.mongodb.com/manual/release-notes/4.0-upgrade-standalone/ for reference
Note: Use the command in the tab that say install specific version of mongodb, it will upgrade mongodb from 3.6 to 4.0.X
Make sure you check value of
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
and then run
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
in mongo shell against admin database after installing version 4.0
Repeat Step 1
If service isn't starting using our --dbpath, and still showing FCV error then delete current db files and extract db files again from the dump
Upgrade to 4.2:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
Use the commad that say install specific version of mongodb, it will upgrade mongodb from 4.0 to 4.2.
https://docs.mongodb.com/manual/release-notes/4.2-upgrade-standalone/ for reference
Make sure you check
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
and run
db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
or set it to 4.2 if you want to use latest features but it makes downgrading later complicated.
mongorestore -d 'simplysmart_api_development' '/home/rohit/Desktop/dump/simplysmart_api_development' (db name should be same)
Tip: When doing this on production if you are unable to start mongod daemon for setting the featureCompatibilityVersion in the mongo shell, create a new folder and run sudo mongod --dbpath '/path/to/new_folder' and then open mongo shell in another terminal and set the featureCompatibilityVersion.