> ## 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](/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.

## Supported Databases

Qovery supports the following managed databases on AWS:

<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](/configuration/environment) where you want to add the database.
  </Step>

  <Step title="Add Database">
    Click the **Add Database** button.
  </Step>

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

    * **Database Type**: PostgreSQL, MySQL, MongoDB, or Redis
    * **Name**: Give your database a name
    * **Version**: Choose the database version
    * **Mode**: Managed (uses AWS managed services like RDS, DocumentDB, and ElastiCache)
  </Step>

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

    * **Instance Type**: Select from available AWS instance types
    * **Storage Size**: Configure storage capacity based on your needs
    * **Storage Type**: Choose storage performance tier (e.g., gp3, io1)
  </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](/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_DATABASE_MY_POSTGRESQL_CONNECTION_URI,
});
```

### Available Environment Variables

For each database, Qovery provides:

* `QOVERY_DATABASE_<DB_NAME>_CONNECTION_URI` - Complete connection string
* `QOVERY_DATABASE_<DB_NAME>_HOST` - Database host
* `QOVERY_DATABASE_<DB_NAME>_PORT` - Database port
* `QOVERY_DATABASE_<DB_NAME>_USERNAME` - Database username
* `QOVERY_DATABASE_<DB_NAME>_PASSWORD` - Auto-generated password
* `QOVERY_DATABASE_<DB_NAME>_DATABASE` - Database name

<Note>
  Replace `<DB_NAME>` with your actual database name (uppercased with underscores). You can find the exact variable names in your application's environment variables settings.
</Note>

## Database Management

### Backups

Backups are handled automatically by AWS managed database services (RDS, DocumentDB, ElastiCache).

## Best Practices

<Tip>
  Choose the appropriate AWS instance type based on your workload. Start with smaller instances and scale up as needed.
</Tip>

<Tip>
  Enable automated backups and set an appropriate retention period for your use case.
</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="/configuration/environment-variables">
    Manage database credentials securely
  </Card>

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

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

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