---
title: "Databases"
description: "Create a PostgreSQL or MySQL database in one click and connect your services to it."
canonical_url: "https://harblet.com/docs/deploy/databases"
---
# Databases

> Create a PostgreSQL or MySQL database in one click and connect your services to it.

Harblet runs PostgreSQL and MySQL databases next to your services. Only services in the same project can connect to them.

<table>
<thead>
  <tr>
    <th>
      Type
    </th>
    
    <th>
      Versions
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      PostgreSQL
    </td>
    
    <td>
      18
    </td>
  </tr>
  
  <tr>
    <td>
      MySQL
    </td>
    
    <td>
      9.7, 8.4
    </td>
  </tr>
</tbody>
</table>

## Create a database

<steps level="3">

### Open the project

Open a project and click **New service** → **Database**.

### Fill in the form

<field-group>
<field :required="true" name="Type">

**PostgreSQL** or **MySQL**.

</field>

<field :required="true" name="Name">

Up to 64 characters. Defaults to the type.

</field>

<field :required="true" name="Version">

The major version. Deploying the database updates it to the newest patch release of this version.

</field>

<field :required="true" name="Username">

Defaults to `postgres` or `root`. Up to 32 lowercase letters, digits and underscores, starting with a letter. PostgreSQL usernames can't start with `pg_`. Can't be changed later.

</field>

<field :required="true" name="Database name">

Defaults to `app`. Up to 63 characters, the same ones as the username. Names the database reserves, such as `template1` or `mysql`, aren't allowed. Can't be changed later.

</field>
</field-group>

### Create it

Click **Create database**. Harblet generates a password and starts the database right away.

</steps>

## Connect to it

The database's **Overview** tab shows its connection details under **Connection**:

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Example
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Host
    </td>
    
    <td>
      <code>
        postgresql-x7k2
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Port
    </td>
    
    <td>
      <code>
        5432
      </code>
      
       for PostgreSQL, <code>
        3306
      </code>
      
       for MySQL
    </td>
  </tr>
  
  <tr>
    <td>
      Database
    </td>
    
    <td>
      <code>
        app
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Username
    </td>
    
    <td>
      <code>
        postgres
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Password
    </td>
    
    <td>
      Generated, hidden until you click the eye button
    </td>
  </tr>
  
  <tr>
    <td>
      Connection URL
    </td>
    
    <td>
      <code>
        postgresql://postgres:<password>@postgresql-x7k2:5432/app
      </code>
    </td>
  </tr>
</tbody>
</table>

Copy the **Connection URL** into an [environment variable](https://harblet.com/docs/deploy/environment-variables) of the service that uses it, such as `DATABASE_URL`, and deploy that service.

- **Only services in the same project** can connect. Other projects and the internet can't reach the database.
- **The host never changes,** also when you rename the database.
- **Every member** of your Harblet can see the password.

<note>

For MySQL with a username other than `root`, Harblet sets a random root password that it doesn't show. Use the username from the connection details.

</note>

## Where the data lives

A database stores its data on the disk of the server it runs on. It stays on that server: if the server fails, the database waits for it to come back, while other services move to another server.

Set up [backups](https://harblet.com/docs/backups/database-backups) so you don't lose data when a disk fails.

## Update to a new patch release

Click **Deploy** on the database. Harblet restarts the database briefly and pulls the newest patch release of its version, for example the newest PostgreSQL 18.x.

If the new release fails to start, Harblet automatically deploys the version that ran before. The deployment list shows it as **Rollback**.

<note>

Harblet doesn't upgrade databases to a new major version, and the version of a database can't be changed.

</note>

## What you can change

Under **Settings**, you can rename the database. Its version, username, database name and password stay as they were created.

Databases have no environment variables, domains or deploy hooks.

## Delete a database

Open the database's **Settings** tab and click **Delete service**. Harblet deletes the database with all its data.

<caution>

This can't be undone. Backups stay at their destination, but Harblet no longer lists them.

</caution>


## Sitemap

See the full [sitemap](https://harblet.com/sitemap.md) for all pages.
