Service Marketplace
Deploy MongoDB

Deploying MongoDB

Zeabur provides a one-click deployment feature of MongoDB service, allowing you to quickly deploy a MongoDB database on Zeabur.

Deploying MongoDB Service

To deploy this service, you will need to create a project first if you haven't done so. You can follow this document to create your project.

In your project, click Add Service and select Marketplace and then search for MongoDB:

Deploy "MongoDB"

Once you click "MongoDB", Zeabur will automatically deploy the MongoDB service for you.

Environment Variables

After the MongoDB service is successfully deployed, Zeabur will automatically inject environment variables into the service. Currently, the following variables are available:

  • MONGO_INITDB_ROOT_PASSWORD
  • MONGO_INITDB_ROOT_USERNAME
  • PASSWORD

Connecting to the Database

ℹ️

The default database user is mongo. The password can be retrieve from the PASSWORD environment variable.

MongoDB Compass

MongoDB Compass (opens in a new tab) is an interactive tool "for querying, optimizing, and analyzing your MongoDB data, and allow getting key insights, dragging and droping to build pipelines, and more".

Once you have downloaded and installed it according to the official documentation, go back to your Zeabur dashboard. Click on the Connections tab in the MongoDB service, and click the eye icon to copy the connection string.

connect-path

Paste the copied content into the URI input box:

input-to-URI

Choose Save & Connect or Connect according to your needs:

mongodb-compass-connect-success

Now you can start to operate MongoDB.

mongosh

mongosh (opens in a new tab) is a fully-featured JavaScript and Node.js REPL environment for interacting with MongoDB databases.

Once you have downloaded and installed it according to the documentation, go back to your Zeabur dashboard. Click on the Connections tab in the MongoDB service, and click the eye icon to copy the connection string.

connect-path

mongosh mongodb://<YOUR_CONNECT_PATH>

Replace <YOUR_CONNECT_PATH> with the connection string you just copied, and we can use the following command to test if the connection is successful:

use mongodb_test
db.mongodb_test.insertOne({content: "Hello World"})
show dbs

If successful, it should return:

mongosh-connect-success

Then we can drop the test database.

use mongodb_test
db.drop()