Can i use xampp for mongodb?

  • Go to your c:/ drive and create a folder “mongodb
  • Download mongoDB from this link: http://www.mongodb.org/downloads (the download button is located under “Community Server” tab)
  • Select “Custom” when installing the software

Can i use xampp for mongodb?

  • Install mongoDB in the following path: c:/mongodb
  • Go to your c:/ drive then create a new folder “data“, inside it create another folder “db
  • Start MongoDB in your command prompt by executing the following command: C:\mongodb\bin\mongod.exe

Can i use xampp for mongodb?

Congratulations, you have successfully installed MongoDB  in Windows.

Moving on, let us now configure XAMPP

  • Download the mongoDB driver from this link: http://windows.php.net/downloads/pecl/releases/mongo/1.6.11/php_mongo-1.6.11-5.6-ts-vc11-x86.zip
  • Open the ZIP file then extract the file: php_mongo.dll to C:\xampp\php\ext directory.
  • Go to xampp/php/ and open up php.ini using your favorite editor, add the following lines to your extensions: extension=php_mongo.dll
  • Restart XAMPP.

To verify that you have successfully configured mongoDB in XAMPP, create a file in your xampp/htdocs folder, in it put the following code:

Now access this file in your browser. Ex. “localhost/testfile.php”

You should see that MongoDB is already installed:

Can i use xampp for mongodb?



Do you need help with a project? or have a new project in mind that you need help with?

Contact Me

Skip to content

Getting started with MongoDB on Windows and developing it with PHP turned out to be quite easy.

You can create a MongoDB database “in the cloud” for free with MongoDB’s Atlas platform – https://cloud.mongodb.com. No credit card required and you’re up and running in under 10 minutes (most of that time is waiting) after filling in a simple form fill and a few button clicks.

Next you need to setup XAMPP if haven’t already. Follow my post Setting up XAMPP for WordPress Development on Windows for details on how to do that. That gives you Apache and PHP running capability.

Finally you need to install MongoDB drivers for PHP under XAMPP. I use https://www.configserverfirewall.com/mongodb/install-mongodb-php-driver-ubuntu-windows/#install-php-mongodb-driver-on-windows to figure that out. The steps are:

  1. Download the drivers for Windows from https://pecl.php.net/package/mongodb and extract the archive (select the “DLL” link for the version you want, scroll to the bottom of the next page, then download from the “DLL List” section for your version of PHP and OS architecture.
  2. Copy the extracted php_mongodb.dll file into <drive>:\xampp\php\ext folder.
  3. Open XAMPP php.ini and add the line: extension=php_mongodb.dll.
  4. Restart the Apache server in XAMPP. You’re good to go.

MongoDB Atlas connection string in PHP

If you run MongoDB locally you’ll have PHP code something link this to establish a connection:

<?php
$connection = new MongoDB\Driver\Manager("mongodb://localhost:27017");
var_dump($connection);
?>

If you connect Atlas use a connection string something like:

new MongoDB\Driver\Manager("mongodb+srv://<db-username>:<db-password>@azure-westus-1-fzl9p.azure.mongodb.net/test?retryWrites=true&w=majority");

Where <db-username> and <db-password> are the username and password you created in Atlas.
“azure-westus-1-fzl9p.azure.mongodb.net” is for my the specific Mongo instance – it will be different for you.

The connection string between the double-quotes is the same as was generated when you go into your collection, select the “Connect” button and follow the prompts.

Post navigation

Can we use XAMPP for MongoDB?

By default, PHP in XAMPP has no mongodb support. So we have to download mongodb extension from PECL (PHP extension repository) and configure it in xampp.

How connect MongoDB to XAMPP?

Installing MongoDB in XAMPP Windows.
Install mongoDB in the following path: c:/mongodb..
Go to your c:/ drive then create a new folder “data“, inside it create another folder “db“.
Start MongoDB in your command prompt by executing the following command: C:\mongodb\bin\mongod.exe..

Can MongoDB be run locally?

You can download and install MongoDB Compass from the this page. To connect to your local MongoDB, you set Hostname to localhost and Port to 27017 . These values are the default for all local MongoDB connections (unless you changed them). Press connect, and you should see the databases in your local MongoDB.

Can I install MongoDB on EC2?

MongoDB Commands: In this way, we can install MongoDB on our EC2 instance using EC2 Instance Connect. And if you also use a free tier account, make sure you delete all the resources you have used before logging out.