Skip to content
Back to blog

Magichosting

Setting up MariaDB for FiveM: database, user and oxmysql

E
Elias Bieber
Estimated reading time: 3 min

ESX and QBCore need a database. How to install MariaDB, create a database and user and connect everything with oxmysql in server.cfg.

FiveMMariaDBoxmysqlESXQBCore

Why FiveM needs a database

Frameworks such as ESX Legacy and QBCore store players, characters, vehicles, jobs and inventories in a MySQL-compatible database. The oxmysql resource connects FiveM to that database. MariaDB runs fastest and easiest on the same server as FXServer – plan 1–2 GB of extra RAM for it.

Step 1: Install MariaDB

Linux in one click

In your KVM server's dashboard, the Autoinstaller tab has an entry for phpMyAdmin. It installs MariaDB and phpMyAdmin in one step – handy if you also want to view tables in the browser later. The FiveM server itself is installed by the FiveM Autoinstaller.

Linux by hand

bash
apt update && apt install -y mariadb-server
mariadb-secure-installation

mariadb-secure-installation removes anonymous users and the test database. On Debian and Ubuntu, MariaDB only listens on 127.0.0.1 by default – exactly right for FiveM.

Windows Server

Download the current MariaDB installer (MSI) from mariadb.org, set a root password and let the service start automatically. You do not need to open port 3306 in the Windows firewall as long as FXServer runs on the same server.

Step 2: Create a database and user

Create a dedicated database and user for FiveM – not root. Open the MariaDB console with mariadb (Linux, as root) or via the MariaDB command line on Windows:

sql
CREATE DATABASE fivem CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'A-LONG-PASSWORD';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;

Step 3: Connect oxmysql in server.cfg

oxmysql reads the credentials from the mysql_connection_string variable. The order matters: set the connection and start oxmysql first, then your framework.

bash
# server.cfg – set the connection before the framework
set mysql_connection_string "mysql://fivem:A-LONG-PASSWORD@localhost/fivem?charset=utf8mb4"

ensure oxmysql
# then the framework, e.g.
ensure es_extended
# or: ensure qb-core

If you use a txAdmin recipe for ESX or QBCore, txAdmin asks for the credentials during setup, creates the tables and writes the connection string into server.cfg itself. For a manual installation, import the SQL files shipped with the resources, for example with phpMyAdmin or mariadb fivem < file.sql.

Step 4: Security and backups

  • Keep port 3306 private: The database doesn't belong on the internet. If you want to access it from home, use an SSH tunnel – our guide reaching MariaDB remotely shows the safe way.
  • One user per server: If you run several FiveM servers, each gets its own database and its own user.
  • Regular dumps: In addition to the backup slots in the dashboard, back up the database as a file – for example daily via a cron job.
bash
# Back up the FiveM database (Linux)
mariadb-dump --single-transaction fivem | gzip > /root/fivem-$(date +%F).sql.gz

# Restore
gunzip -c /root/fivem-2026-11-24.sql.gz | mariadb fivem

More on hardening in running MariaDB and MySQL securely.

Frequently asked questions

MariaDB or MySQL for FiveM?

Both work with oxmysql. MariaDB is the default package on Debian and Ubuntu, quick to install and recommended by ESX and QBCore.

How much RAM does the database need?

For a typical roleplay server, 1–2 GB extra is enough. If the database grows a lot, for example through extensive logs or many vehicles, check table sizes and indexes.

Does the database run better on a separate server?

Not for most FiveM projects: on the same server, latency is minimal. A separate database server only pays off for very large projects or several game servers sharing one database.

Which server fits FiveM with a database?

For 20–30 players with ESX or QBCore, 4 vCores and 16 GB RAM on the AMD Ryzen 9 9950X are a good start. You'll find the recommended sizes with live prices on our FiveM server hosting page.

Was this post helpful?

MagicHosting – Hosting with real value

Hosting pays off with MagicHosting: fair pricing, current deals and operation in SkyLink RZ. Servers, domains and personal support – no hidden costs.

  • Current limited offers from our server exchange
  • Affordable domains with transparent pricing and great offers
  • Powerful DDoS protection for maximum availability
  • Personal support when you have questions or issues