> ## Documentation Index
> Fetch the complete documentation index at: https://www.qovery.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Database

> Learn how to create and connect databases to your applications

<Note>
  **Haven't deployed an app yet?** Start with the [Quick Start Guide](/docs/quickstart) to set up your first application, then return here to add a database.
</Note>

## Overview

This guide shows you how to create a database in your environment and connect it to your application.

<Tip>
  For production, deploy a cloud provider managed database (for example Amazon RDS for PostgreSQL or MySQL, or Amazon ElastiCache for Redis) with a [Blueprint](/docs/configuration/blueprints). See [Creating a Blueprint Service](/docs/configuration/blueprints#creating-a-blueprint-service).
</Tip>

## Supported Databases

Managed databases are supported through [Blueprints](/docs/configuration/blueprints). For development and testing, Qovery can also deploy the following databases as containers on your cluster, as described in this guide:

<CardGroup cols={2}>
  <Card title="PostgreSQL" icon="database">
    Most popular relational database
  </Card>

  <Card title="MySQL" icon="database">
    Traditional relational database
  </Card>

  <Card title="MongoDB" icon="database">
    Document-oriented NoSQL database
  </Card>

  <Card title="Redis" icon="database">
    In-memory key-value store
  </Card>
</CardGroup>

## Creating a Database

<Steps>
  <Step title="Navigate to Your Environment">
    In the Qovery Console, go to your project and select the [environment](/docs/configuration/environment) where you want to add the database.
  </Step>

  <Step title="Add a Database via New Service">
    Click the **New Service** button, then either:

    * Select **Database** from the service type list, or
    * Search directly for the database you want (e.g., "MySQL", "PostgreSQL")
  </Step>

  <Step title="Configure Basic Settings">
    Configure your database:

    * **Database Type**: PostgreSQL, MySQL, MongoDB, or Redis
    * **Name**: Give your database a name
    * **Version**: Choose the database version
  </Step>

  <Step title="Configure Resources">
    Set the resource allocation for your database:

    * **vCPU**: CPU assigned to the database container
    * **Memory**: RAM assigned to the database container
    * **Storage**: Size of the persistent storage attached to the database
  </Step>

  <Step title="Create and Deploy">
    Review your settings and click **Create**. You can choose to create the database alone or create and deploy it immediately.
  </Step>
</Steps>

## Connecting Your Application

Qovery automatically injects database credentials as [environment variables](/docs/configuration/environment-variables) when your application runs. You'll have access to a connection URI and individual connection details.

### Using the Connection URI

The easiest way to connect is using the connection URI environment variable:

```javascript theme={null}
// Node.js with PostgreSQL example
const { Pool } = require('pg');

const pool = new Pool({
  connectionString: process.env.QOVERY_POSTGRESQL_Z9XXXXXX_DATABASE_URL,
});
```

### Available Environment Variables

For each database, Qovery provides:

* `QOVERY_POSTGRESQL_<DBID>_DATABASE_URL` - Complete connection string
* `QOVERY_POSTGRESQL_<DBID>_HOST` - Database host
* `QOVERY_POSTGRESQL_<DBID>_PORT` - Database port
* `QOVERY_POSTGRESQL_<DBID>_LOGIN` - Database username
* `QOVERY_POSTGRESQL_<DBID>_PASSWORD` - Auto-generated password
* `QOVERY_POSTGRESQL_<DBID>_DEFAULT_DATABASE_NAME` - Default database name

Replace `POSTGRESQL` with your actual database type (`MYSQL`, `MONGODB`, `REDIS`, etc.) and `<DBID>` with the database ID shown in the Console (visible in the **Variables** tab of your service).

<Note>
  The exact variable names are always visible in the **Variables** tab of any service that has the database attached. You can copy them directly from there.
</Note>

## Database Management

### Backups

Databases created this way run as containers and have no automated backups or snapshots. For production, provision a cloud provider managed database with a [Blueprint](/docs/configuration/blueprints) and configure and verify the provider's backup and retention settings.

## Best Practices

<Tip>
  Start with small CPU and memory values and scale up as needed. For production workloads, use a [Blueprint](/docs/configuration/blueprints) to provision a managed database.
</Tip>

<Warning>
  Database passwords are generated automatically. Store them securely and rotate regularly.
</Warning>

## Next Steps

<CardGroup cols={2}>
  <Card title="Environment Variables" icon="key" href="/docs/configuration/environment-variables">
    Manage database credentials securely
  </Card>

  <Card title="Database Configuration" icon="sliders" href="/docs/configuration/database">
    Advanced database configuration
  </Card>

  <Card title="Database Seeding" icon="seedling" href="/docs/getting-started/guides/others/database-seeding-lifecycle-job">
    Initialize your database with sample data
  </Card>

  <Card title="Lifecycle Jobs" icon="clock" href="/docs/configuration/lifecycle-job">
    Automate database tasks during deployment
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.