Many FiveM resources, including frameworks such as ESX and QBCore, store their data in a MySQL database. This guide walks you through creating a database, connecting your server to it with oxmysql, and checking that the connection works.
If you set up your server with a txAdmin recipe that uses a database, txAdmin may have already asked for your database details and connected it for you. Check your
server.cfgfor amysql_connection_stringline before you start.
You will need:
main.
Select your new database to open its Database connection details. You will need four values from it:
| Value | Where to find it |
|---|---|
| Username | The Username field. |
| Password | The Password field, copied exactly as shown. |
| Host and Port | The Endpoint field, written as host:port. For example, pma.n1.imperial-hosting.net:3306. |
| Database name | The end of the JDBC Connection String, after the last /. For example, s154_main. |

Anyone with these details can read, change, or delete your server's data. Do not share them in public Discord channels, screenshots, or support tickets.
oxmysql is the resource that connects your server to MySQL. Most framework recipes include it already.
resources folder.oxmysql. It may be inside a category folder, such as [standalone] or [core].If you cannot find it, download the latest release from the oxmysql GitHub page and install it. See Installing a Resource.
Some older resources ask for mysql-async or ghmattimysql instead. These libraries are no longer maintained, and oxmysql works in their place for most resources. Install oxmysql unless the resource's developer says otherwise.
server.cfg in your .base folder.ensure oxmysql line.set mysql_connection_string "mysql://USERNAME:PASSWORD@HOST:PORT/DATABASE"
ensure oxmysql
For example:
set mysql_connection_string "mysql://u154_AbCdEf123:Pa55.w0rd^[email protected]:3306/s154_main"
Your
server.cfgshould only have onemysql_connection_stringline. If one already exists, replace it instead of adding a second one.Any resource that uses the database must be listed below
ensure oxmysqlinserver.cfg, so the database connection is ready before the resource starts.
Restart your server from the Console. While it starts, watch for a message from oxmysql saying the database connection was established.
If you see an error instead, check the table below.
| Error mentions | What it means |
|---|---|
Access denied for user |
The username or password is wrong. Copy them again from your connection details. |
ENOTFOUND or ECONNREFUSED |
The host or port is wrong. Check them against the Endpoint field. |
Unknown database |
The database name is wrong. Copy it again from the end of the JDBC Connection String. |
Once oxmysql is connected, set up the database for the resource you are installing by following the developer's documentation. Some resources create what they need automatically the first time they start, while others include a .sql file you need to import yourself.
Learn more about your database's connection details and how to rotate its password.
Install oxmysql or any other resource on your server.
If you run into any issues or need support, our team is here to help.
Join our Discord.
Open a support ticket through our Help Desk.