How to upgrade MongoDB on Windows Server
Edit:First start the cmd.exe in admin mode and cd to the location of the old installation, for standard installations:
cd C:\Program Files\MongoDB\Server\3.2\bin
Stop all applications, which are accessing mongodb, then enter
mongod --remove
Then install the new mongo db, copy the mongod.cfg file from 3.2 to 3.4 directory. When you had one, otherwise follow the installation instructions for setting up the new service. This update worked fine for me, all data available, I didn't need to use this features switched off.
I upgraded from version 3.6.0 to 3.6.2 just today and below are the steps involved:
- Download the latest version from the [mongodb wesbite][1].
- When downloading is complete, stop any running instance of mongodb by typing 'Ctrl+C' on the command console.
- Run the installation file and it automatically installs the new version at the same path as the previous version (at C:\ProgramFiles\MongoDB\Server\3.6).
- Start the database server by typing 'mongod'.
- All previous databases will be accessible to you.
Windows MongoDB major version upgrade can be performed easily in-place
, here i am describing the steps to upgrade MongoDB 4.2 to 4.4 with existing data directory. You can follow the same for any version upgrade.
We will use the Windows command prompt
to perform all steps below:
- For safety take a backup of existing DB, provide a path to backup them
cd C:\Program Files\MongoDB\Server\4.2\bin
mongodump -o D:\DB_backup
- Stop all the application writes and shutdown the MongoDB service
type "services. msc" and hit Enter or press OK
Services -> MongoDB Server -> Right click & stop
- Install the new MongoDB mongodb-windows-x86_64-enterprise-4.4.8-signed.msi file msi package by using GUI provide the old exixting directories. Meanwhile rename directory from 4.2 to 4.4
Data dir - D:\MongoDB\Server\4.4\data
Log dir - D:\MongoDB\Server\4.4\log\
This will replace all the bin files with older version ones and MongoDB will be started automatically.
- Finally , move to the bin directory, run mongo.exe client and check the DB availablity
cd C:\Program Files\MongoDB\Server\4.4\bin