# Host a MySQL or MariaDB database

A MySQL or MariaDB database online all the time: your AI agent creates it on Estiba with its password and its files kept, and you pay for what it uses.

## Put it online

1. [Sign up](https://app.estiba.cloud) and [connect your agent](https://estiba.cloud/docs/connect-your-agent) to Estiba, once.
2. Ask it: "create a MariaDB database on Estiba" (or MySQL, which works the same way).
3. Your agent creates it from the official image, with a version of your choice that only changes when you say so. It keeps the database's files in a volume, at `/var/lib/mysql`, so they last when it restarts or moves. The root password goes in as a secret: stored encrypted and never shown again, not even to the agent, so keep the one it gives you.
4. It gives the database a port and tells you its address, such as `ports.estiba.cloud:21450`.
5. [Add credit](https://estiba.cloud/docs/credit-and-prices), from $5. The database starts once there is credit.

Your agent also sets a longer stop time, so the database always shuts down cleanly before a restart or a move.

## Connect to it

Use the address and port with any client: HeidiSQL, DBeaver, TablePlus, MySQL Workbench or your app's own driver. For example:

```
mysql -h ports.estiba.cloud -P 21450 -u root -p
```

Your apps on Estiba connect to the same address, wherever each one runs. Ask your agent to create a database and a user for each app, with its own password, rather than using root.

The address is open to the internet, like any database on a port: the password is what keeps others out, so use a long one. The connection is not encrypted unless the database is set up with TLS: for data that matters from outside Estiba, ask your agent to turn it on.

Is the database on a server of your own instead? Your app on Estiba reaches it over a [private network](https://estiba.cloud/docs/private-network-wireguard), without opening its port to the internet.

## For a FiveM server

A FiveM server with oxmysql or mysql-async points its `server.cfg` to this address. Ask your agent to do both at once; see [Host a FiveM server](https://estiba.cloud/docs/fivem-server-hosting).

## What it costs

You pay for what it uses, measured every second: $4 per GB of memory and $8 per vCPU busy, a month, and $0.10 per GB its files take, taxes included. Your agent keeps it always on, so it never sleeps and your apps always find it.

For example, a MariaDB measured on Estiba, the database of a FiveM roleplay server and its test server, holds about 450 MB of memory, keeps 9.4 % of a vCPU busy and its files take 1.1 GB: 0.45 × $4 + 0.094 × $8 + 1.1 × $0.10 = **about $2.70 a month**. A small app's database uses less. The dashboard shows what yours really uses and costs each day.

## Back it up

Ask your agent for a dump: it runs `mariadb-dump` (or `mysqldump` for MySQL) against the address and saves the file on your computer. Don't copy the database's files from the volume while it runs; a dump is the safe copy.

## If a server goes down

The database keeps its files in its volume, so if the machine it runs on goes down, it waits for it to come back instead of starting somewhere else without them. When Estiba moves it to another machine, its files go with it and the address stays the same; the move restarts it for a few seconds and apps reconnect.
