Setting up MariaDB for a FiveM server
ESX, QBCore, Qbox and nearly every roleplay script store their data in a MySQL-compatible database, reached through oxmysql. Setting it up is a one-time job: install MariaDB, create a database and a user, and give oxmysql the connection string.
Short answer: Install MariaDB (apt install mariadb-server on Debian/Ubuntu, the MSI installer on Windows), run mariadb-secure-installation, then create a utf8mb4 database and a dedicated user with rights only on it. Add set mysql_connection_string "mysql://user:password@localhost/dbname?charset=utf8mb4" to server.cfg and make sure oxmysql starts before your framework. Keep port 3306 closed to the internet.

#Installing
apt update && apt -y install mariadb-server
mariadb-secure-installationOn Windows, download the MariaDB MSI installer from mariadb.org, set a root password during setup and keep “Enable access from remote machines” off. XAMPP is fine for local testing but not for a live server.
#Creating the database and user
CREATE DATABASE fivem CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'a-long-random-password';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;Framework recipes in txAdmin can create the database for you when you give them credentials. Either way, import the framework’s SQL files into this database.
#Connecting oxmysql
set mysql_connection_string "mysql://fivem:a-long-random-password@localhost/fivem?charset=utf8mb4"
ensure oxmysql
ensure ox_lib
ensure qbx_core # or es_extended / qb-coreSpecial characters in the password must be URL-encoded in this form (for example @ becomes %40), or use the key-value format oxmysql also accepts. Script-side usage is in the oxmysql guide.
#Looking inside the database
- HeidiSQL (Windows) — connect over SSH tunnel to a remote server instead of opening 3306.
- DBeaver (cross-platform) — same idea.
- phpMyAdmin — only behind a login you control, never public without protection.
#Basic tuning and safety
| Setting | Suggestion |
|---|---|
bind-address | 127.0.0.1 so only the local machine can connect |
innodb_buffer_pool_size | A good share of spare RAM (for example 1–4 GB on a dedicated game box) |
| Slow query log | Enable briefly to find slow script queries |
| Backups | Daily dumps — see server backups |
Questions
Should I use MariaDB or MySQL for FiveM?
What is the oxmysql connection string?
set mysql_connection_string "mysql://user:password@host/database?charset=utf8mb4" in server.cfg.Why does oxmysql say access denied?
Should I open port 3306?
Ready to pick a map?
Twelve themes on three base map styles, $8 each, instant download.