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

# Database Setup

> Connect oxmysql, mysql-async, or txAdmin to a Lumi-Panel database.

Most FiveM frameworks (ESX, QBCore, QBox, ND) need a MariaDB database. On Lumix Solutions, that's a one-click provision in the [Databases](/lumi-panel/management/databases) tab.

## 1. Create the database

In Lumi-Panel:

1. Open **Databases**.
2. Click **New Database**, give it a name like `fivem`, leave **connection from** as `%`.
3. Save the **Endpoint**, **Username**, and **Password** - you'll need them next.

You can also manage it through phpMyAdmin at [db.lumixsolutions.org](https://db.lumixsolutions.org) using the same credentials.

## 2. Import your framework's schema

Sign in to [db.lumixsolutions.org](https://db.lumixsolutions.org), select your database in the left sidebar, click **Import**, and upload your framework's `.sql` file (e.g. ESX's `legacy.sql`, QBCore's `qb-core.sql`).

## 3. Configure the connection string

### oxmysql (recommended)

In `server.cfg`:

```cfg theme={null}
set mysql_connection_string "mysql://USERNAME:PASSWORD@HOST:PORT/DATABASE?charset=utf8mb4"
ensure oxmysql
```

Replace `USERNAME`, `PASSWORD`, `HOST`, `PORT`, and `DATABASE` with the values from the Databases tab.

### mysql-async (legacy)

```cfg theme={null}
set mysql_connection_string "server=HOST;port=PORT;database=DATABASE;userid=USERNAME;password=PASSWORD"
ensure mysql-async
```

## Configuring the database in txAdmin

When you run through txAdmin's setup wizard (or change the database later under **Settings → Server**), it asks for the database host, port, username, password, and database name separately.

<Warning>
  Use the **Endpoint** from the Databases tab - not your server's game IP. Your FiveM server and the database run on **different IPs**. Typing your server's IP here will fail to connect every time.
</Warning>

The Lumi-Panel **Endpoint** looks like `DB_HOST:DB_PORT` (for example `db.example.lumixsolutions.org:3306`). Split it into the two fields txAdmin asks for:

| txAdmin field      | Value                           | Example       |
| ------------------ | ------------------------------- | ------------- |
| **MySQL Host**     | The part **before** the `:`     | `DB_HOST`     |
| **MySQL Port**     | The part **after** the `:`      | `DB_PORT`     |
| **MySQL User**     | Username from the Databases tab | `DB_USERNAME` |
| **MySQL Password** | Password from the Databases tab | `DB_PASSWORD` |
| **MySQL Database** | The full database name          | `DB_NAME`     |

If you'd rather paste a single string, the **JDBC connection string** field in Lumi-Panel already has every value baked in:

```text theme={null}
jdbc:mysql://DB_USERNAME:DB_PASSWORD@DB_HOST:DB_PORT/DB_NAME
```

Use that as a reference - the values between the symbols are exactly what each txAdmin field wants.

## 4. Restart

Restart the server from the [Console](/lumi-panel/general/console). On boot you should see something like:

```text theme={null}
[oxmysql] Database server connection established!
```

If you see `ECONNREFUSED`, `Access denied`, or `Unknown database`, walk through [Startup Issues → Database connection refused](/games/fivem/startup-issues#database-connection-refused-on-boot).

## Best practices

* **Never commit credentials.** Keep `server.cfg` out of public repos, or use a separate `secrets.cfg` that's gitignored.
* **Rotate the password** from the Databases tab if you suspect a leak - then update `server.cfg` and restart.
* **Back up before big changes.** Use phpMyAdmin's **Export** or trigger a panel-wide [Backup](/lumi-panel/management/backups) before running schema migrations.
