⚔️ Valheim 1.0 is out: 25% off with codeSP25
FivemFivem·Server Administration

How to Connect a Database to Your FiveM Server

Connect MySQL to FiveM for ESX or QBCore: map host, port, name, user and password into the oxmysql connection string, then import the SQL and fix common errors.

Noah
·
6 min read
·
September 25, 2026
Table of Contents

ESX and QBCore keep everything in MySQL: characters, inventories, money, vehicles, jobs. Without a working database they do not start at all. The good news is that the whole connection comes down to one line in server.cfg, built from five values the panel already shows you. Here is how to fill it in and get the framework tables imported.

What you need

  • Your FiveM server in the game panel
  • oxmysql in your resources folder (ESX and QBCore both ship with it or list it as a requirement)
  • The SQL files that came with your framework, if you are not installing through a txAdmin recipe

Step 1: create the database

Open your server in the game panel and click Databases in the menu. Click New database, type a short name such as qbcore or esx (letters, numbers and underscores only) and confirm.

The panel adds a prefix, so qbcore ends up as something like s1234_qbcore. The database user carries the same prefix, so the two look almost identical. Swapping them is a classic mistake.

If you only see Databases not available, the server has no database slot. Contact us from the support page and we will sort it out.

Step 2: map the panel fields to the connection string

Each database in the list shows five values, each with its own copy button. This is where every one of them goes:

Panel field In the URI form In the key=value form
Database name after the / database=
Host between @ and : host=
Port after the : port=
Username before the : user=
Password between : and @ password=

Four rules keep you out of trouble:

  • Host is the address only. The panel shows the port in its own field. Do not paste address:3306 into the host slot, or the port ends up in the string twice.
  • Never localhost or 127.0.0.1. Your database runs on our separate database host, not inside the game server. Tutorials use localhost because they assume MySQL on the same PC as FXServer.
  • Never root. Only the username the panel shows will log in.
  • Use the exact prefixed name. Installers suggest names like es_extended or qbcore, which do not exist on your account. Copy Database name from the panel.

Step 3: add the line to server.cfg

The quick way

On a FiveM server the Databases tab shows an extra card under the list called oxmysql connection string. It holds the finished set mysql_connection_string "..." line for your first database, in whichever format safely carries your password. Use its copy button: it copies the real password even while the screen shows dots.

Writing it by hand

oxmysql accepts two formats. The URI form looks like this:

set mysql_connection_string "mysql://USERNAME:PASSWORD@HOST:PORT/DATABASE?charset=utf8mb4"

The key=value form carries exactly the same information:

set mysql_connection_string "user=USERNAME;password=PASSWORD;host=HOST;port=PORT;database=DATABASE;charset=utf8mb4"

Replace each placeholder with the matching value from the table. charset=utf8mb4 is optional, but keep it so player names with special letters are stored correctly.

Where server.cfg lives and where the line goes

Open the Files tab. With the default setup, server.cfg sits in the main folder next to the resources folder, and the server loads it on every start.

Order matters. oxmysql reads the setting once, the moment it starts, so the file must look like this from top to bottom:

set mysql_connection_string "..."

ensure oxmysql
ensure es_extended

The connection string first, then ensure oxmysql, then your framework (qb-core instead of es_extended on QBCore). If the line sits below ensure oxmysql, it is read too late.

If you switched on txAdmin with the Enable txAdmin button on your server page, the server no longer loads that file. txAdmin starts it with the server.cfg from its own server data folder instead. Click Open txAdmin and add the line in its CFG Editor, or the change never reaches the running server.

Step 4: restart and check the console

Restart the server from the panel. A full restart is required, because the setting is only read when the server starts. Restarting the oxmysql resource on its own is not enough.

Watch the Console tab while it boots. When it works, oxmysql reports that it connected along with the database server version, and your framework loads without SQL errors. When it does not, the error appears within seconds and matches one of the cases below.

Importing the ESX or QBCore SQL files

The framework expects its tables to exist, so its SQL files must be imported once.

With a txAdmin recipe. txAdmin's recipe deployer asks for database details along the way. Enter the host, port, username and password from the panel, and replace the suggested database name with your prefixed one. The deployer then runs the SQL and writes the connection string for you.

By hand. The panel has no SQL import tool of its own, so use a MySQL client on your own computer. HeidiSQL and DBeaver both work: create a MySQL connection with the five values from the panel, then run the .sql file against your database. From a command line it looks like this:

mysql -h HOST -P PORT -u USERNAME -p DATABASE < es_extended.sql

Before you import, open the SQL file in a text editor. Some framework files start with CREATE DATABASE and USE lines pointing at their own database name. Delete those lines, otherwise the import tries to reach a database you have no access to and fails.

Import the framework's main file first, then the SQL that comes with each extra resource.

Troubleshooting

Access denied for user. The username or password does not match. Usually it is a typo, a password rotated with New password after you wrote the config, or special characters breaking the line. Every variant is covered in fixing oxmysql Access denied.

connect ECONNREFUSED or ETIMEDOUT. oxmysql cannot reach the database, so this is an address problem, not a password problem. Use the host from the panel instead of localhost or 127.0.0.1, and check that the port is right and appears only once.

Unknown database. The database name is missing its prefix, or the username went where the database name belongs. Copy Database name from the panel again.

Special characters in the password. Many guides say to URL-encode symbols in the URI form, turning @ into %40. Not with oxmysql: it does not decode them, so %40 is sent as part of the password and the login fails. Paste the password exactly as shown, or copy the line from the card, which already uses a format your password fits. If the card shows a warning instead, click Generate new password.

Table doesn't exist. oxmysql connects, but ESX or QBCore reports missing tables. The SQL files have not been imported, or they went into another database. Import them as described above.

It worked yesterday. Somebody clicked New password on the database. The old password stops working immediately, so copy the new line into server.cfg and restart.

Still stuck? Open a ticket from the support page with your server name and the console error, with the password removed. Looking for a server first? See our FiveM server hosting.

Fivem

Ready to play Fivem?

Get your own server running in minutes.