Add a MongoDB Driver
Overview
In this guide, you will learn how to add a MongoDB driver to your project.
Time required: 5 minutes
What You'll Need
An environment configured for your programming language.
Procedure
Tip
Use the language selector above to switch between languages.
Add the MongoDB .NET/C# driver using NuGet
. Use MongoDB.Driver
for all new projects.
.NET CLI
dotnet add package MongoDB.Driver --version 2.17.0 Package Manager
PM > Install-Package MongoDB.Driver -Version 2.17.0 Package Reference
<PackageReference Include=MongoDB.Driver" Version="2.17.0" />
Add the MongoDB Go driver using go mod
.
mkdir guides cd guides go mod init guides go get go.mongodb.org/mongo-driver/mongo
Add the MongoDB Java driver to your project in one of the following ways:
If you are using Maven, add the following to your
pom.xml
dependencies list:<dependencies> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver-sync</artifactId> <version>4.7.0</version> </dependency> </dependencies> If you are using Gradle, add the following to your
build.gradle
dependencies list:dependencies { implementation 'org.mongodb:mongodb-driver-sync:4.7.0' }
Once you configure your dependencies, ensure they are available to your project which may require running your dependency manager and refreshing the project in your IDE.
Add the MongoDB Node.js driver to your project using npm
.
npm install mongodb
Add the MongoDB Python driver, Pymongo, using pip.
python3 -m pip install 'pymongo[srv]'
Summary
If you successfully completed the procedure in this guide, you have added a MongoDB driver to your project.
In the next guide, you'll learn how to retrieve data from MongoDB.
See Also
For other CRUD guides: