mongoDB

Running multiple versions of mongodb on Windows

To setup you developer computer with mongoDB you can go to https://www.mongodb.com and run the latest msi. This will install all the things you need within minutes. All you need to do to get an instance of mongoDB up and running is good documented here. It is a great place to start working with mongoDB.

On the other hand, if you want to be able to keep working with the latest versions and also have access to older versions in case of fallbacks or restore of data and so on, I will show you my way of setting up and running mongoDB.

https://www.mongodb.org/dl/win32/x86_64-2008plus  provides you with a zip file of the binaries so you can start the version you want at any given time. This is super convenient for so many reasons and the only thing you need to worry about is to start the right version and make sure you provide a different db path.

 

For each version you want to keep in your system I follow two steps.

  1. Create a folder with the mongoDB version name like “C:\mongodb-3.2.8”

mm1

Extract your downloaded zip of mongoDB to this folder and create 2 new folders. Data and log.

  1. Create a mongoDB configuration file to set up the environment.

I have created a file mongod.cfg inside the current folder. In this configuration file, you can specify all the things you need to run your instance on mongoDB. In this case I only need to specify the dbpath and the path to the log file.

mm2

To start your instance of version 3.2.8 of mongoDB, open a cmd and type “start C:\mongodb-3.2.8\bin\mongod.exe –config C:\mongodb-3.2.8\mongod.cfg”

To connect to mongoDB using the shell you can type “c:\mongodb-3.2.8\bin\mongo.exe”.

mm3

Note that if you do not specify the name of the database you want to connect to you will enter a database named “test”.

 

If you want to enter another database, simply type “use [database name]”. You don’t even have to create a database. There are now schemas in this database yet. Until you actually insert some data there are no data files needed. You can check what database you currently are connected to by simply typing “db”

mm4

When you do an insert on the current database, mongoDB will create the data files needed.

Type “show collections” to see the result.

mm5

Thanks for reading.

 

 

 

 

2 thoughts on “Running multiple versions of mongodb on Windows

Comments are closed.