FiveM Updated April 27, 2026

Setting Up MySQL/MariaDB for FiveM

How to install MySQL or MariaDB, create a FiveM database, and configure oxmysql on your server.

FiveMMySQLMariaDBoxmysqlDatabase

Overview

ESX and QBCore both require a running MySQL or MariaDB instance to store player data, inventories, jobs, and vehicle registrations. oxmysql is the resource that bridges FXServer to the database. This guide covers installing the database engine, creating the FiveM schema, and wiring up the connection string.

Choosing MySQL vs. MariaDB

MariaDB is the recommended choice for most FiveM servers. It is a drop-in MySQL replacement, performs better under the write-heavy workload of an active RP server, and is the default in most Linux package managers.

Installing MariaDB on Linux

# Debian / Ubuntu
sudo apt update
sudo apt install mariadb-server -y
sudo systemctl enable --now mariadb
sudo mysql_secure_installation

For other distributions, substitute mariadb-server with the equivalent package name.

Creating the Database and User

Log into the MariaDB shell:

sudo mysql -u root -p

Run these SQL statements to create a dedicated FiveM database and user:

CREATE DATABASE fivem CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Use localhost if FXServer and MySQL run on the same host. If they run on different machines, replace localhost with the FXServer host IP and adjust your firewall to allow port 3306.

Importing Framework SQL

ESX

mysql -u fivem -p fivem < ~/FXServer/server-data/resources/[esx]/es_extended/sql/es_extended.sql

QBCore

mysql -u fivem -p fivem < ~/FXServer/server-data/resources/[qb]/qb-core/sql/qb-core.sql

Always import a resource's SQL file before starting that resource for the first time.

Configuring the oxmysql Connection String

In server-data/server.cfg, add the connection string convar before ensure oxmysql:

set mysql_connection_string "mysql://fivem:StrongPasswordHere@localhost/fivem?charset=utf8mb4"

The format is:

mysql://USER:PASSWORD@HOST/DATABASE?OPTIONS

Common options:

Option Purpose
charset=utf8mb4 Supports full Unicode including emoji
connectTimeout=30000 Milliseconds to wait for connection
waitForConnections=true Queue queries if pool is exhausted

Verifying the Connection

Start FXServer and look for the following line in the txAdmin console:

[oxmysql] Database connection established.

If you see MySQL connection failed, check:

  1. The username and password are correct.
  2. The database name matches exactly (case-sensitive on Linux).
  3. MariaDB is running: sudo systemctl status mariadb.
  4. The user has GRANT ALL on the database.
  5. No typos in the connection string — quote characters and special characters in passwords need escaping.

Using a Panel-Provided Database

Some hosting panels pre-provision a MySQL instance. In that case:

  1. Find the database credentials in the panel's Databases tab.
  2. Import SQL files using the panel's phpMyAdmin link or through the FXServer startup script.
  3. Use the provided host (often 127.0.0.1 or an internal hostname), port, user, and password in the connection string.