How to Set Up a MySQL Database for Your FiveM Server

Create a MySQL database on your FiveM server, configure oxmysql, and import .sql files for ESX or QBCore frameworks.

Both ESX and QBCore store player data, vehicles, jobs, and economy in a MySQL database. The standard connector is oxmysql (replaces the older mysql-async and ghmattimysql).

Create a Database

Open the Databases tab

In the XGamingServer Panel, click Databases in the sidebar.

Create a new database

Click New Database. Note the generated credentials:

  • Host (e.g., 127.0.0.1)
  • Port (e.g., 3306)
  • Database name
  • Username
  • Password

You'll need these for the connection string.

Configure oxmysql

Add the connection string to your server.cfg (via Files in the sidebar):

set mysql_connection_string "mysql://dbuser:dbpassword@127.0.0.1:3306/dbname?charset=utf8mb4"

Alternative format (for passwords with special characters)

If your password contains ;, /, ?, @, &, =, +, $, or #, use the semicolon format:

set mysql_connection_string "user=dbuser;password=dbpassword;host=127.0.0.1;port=3306;database=dbname"

Then ensure oxmysql starts before any framework resources:

ensure oxmysql
ensure es_extended  # or ensure qb-core

Import .sql Files

Framework installation requires importing an SQL file that creates the database tables. If the txAdmin recipe handled this automatically, you can skip this step.

Open phpMyAdmin

From the Databases tab on the panel, click the phpMyAdmin link (or access it directly).

Select your database

Click your database name in the left sidebar.

Import the SQL file

Click the Import tab. Click Choose File and select the .sql file:

  • ESX: legacy.sql (from the esx_core download)
  • QBCore: qbcore.sql (from the txAdmin recipe)

Click Go to import.

Verify the Connection

After starting the server, check Console for:

[oxmysql] Connected to database

If you see connection errors, check:

ErrorFix
Access denied for userWrong username or password in the connection string
Unknown databaseDatabase name doesn't match — check Databases tab
AUTH_SWITCH_PLUGIN_ERRORMySQL 8+ auth issue. Set the user to mysql_native_password authentication
Connection refusedWrong host/port, or database server not running
Connection string with special chars failsSwitch to semicolon format

How is this guide?

40% Off — Limited TimeGet your Fivem server todayInstant setup, DDoS protection, and 24/7 support included.
Get a Server

On this page