How to install MongoDB on Windows to run with XAMPP

Oh yeah. Today i installed XAMPP into c:\xampp to work with a local environment at my Windows 10 Pro Computer. But instead of MySQL i wanted to use MongoDB. 

After installing XAMPP i installed MongoDB Server Community Edition. First i tried to custom install the software at c:\mongodb  but then the database service won’t start. So after messing around and trying to get it fixed i gave up and installed MongoDB with the default path into C:\Program Files\MongoDB  Works perfect and the service is running without producing errors. I also downloaded MongoDB Compass Community Edition for having a nice visual database editor. 

To insert MongoDB into XAMPP i needed to download the MongoDB driver. to get the installed version of XAMPP i added a index.php file to my C:\xampp\htdocs\xampp  directory with the followng content: 


After i’ve saved the file i opened my browser with http://localhost/xampp/ to get the PHP info displayed.

Line four shows the architecture of the installed PHP version. This can be x86 or x64. This information is needed to load the correct package for MongoDB from the PECL repository. 

After this we browse to, select the newest version for and click on the DLL-Link to get the driver DLL for Windows.

Then we select the driver matching our PHP version and architecture. I have PHP 7.2.x and x86 as seen at the phpinfo()

Downloading and unzipping the downloaded file, we’ll find the php_mongodb.dll. Copy this file and add it to your extension path of your XAMPP installation under C:\xampp\php\ext . After that edit your php.ini file at C:\xampp\php\php.ini  and add the line 


around line 909 at the “Dynamic Extensions” section of your php.ini  file. Safe the php.ini-file and restart your Apache server through the XAMPP control panel.

After that check http://localhost/xampp/ again and search for “mongodb”. You should see something like: 

Now you’re done and MongoDB is available within your XAMPP environment.
Happy databaseing, Mongo! πŸ™‚

7 thoughts on “How to install MongoDB on Windows to run with XAMPP

  1. I want to ask that if it is really necessary to install xampp before installing mongodb or if I can directly install mongodb for my use?

    • Sorry for replying so late. No you don’t need to install XAMPP before installing MongoDB but I recommend doing so if you want to use MongoDB within XAMPP and its PHP.

  2. Really great! A step by step instruction to the point! πŸ™‚
    Today, Compass was integrated with the MongoDB installer. So I had not to install Compass seperately.
    Thanks! πŸ™‚

  3. One Little typo:
    Modifying the php.ini file, You don’t need to include the .dll extension
    The line should read:
    Thanks for a great info page.

Leave a Reply

Your email address will not be published. Required fields are marked *