Secure client portal

Database & SQL

How to Set Up MySQL/MariaDB for FiveM and QBCore

Create a MariaDB database and user for FiveM frameworks like QBCore, configure oxmysql, and avoid exposing port 3306 to the internet.

QBCore, Qbox, ESX, and most modern economies expect a MySQL-compatible database. On Linux, MariaDB is the usual choice. This guide covers a clean local setup for oxmysql.

Install MariaDB (Linux VPS sketch)

sudo apt update
sudo apt install -y mariadb-server
sudo mysql_secure_installation

Create database and user

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

oxmysql connection string

In server.cfg (syntax per current oxmysql docs):

set mysql_connection_string "mysql://fivem:PASSWORD@127.0.0.1/qbcore?charset=utf8mb4"
ensure oxmysql

Import framework SQL before expecting characters to save. Use the SQL files shipped with your framework version.

Security

  • Bind MariaDB to 127.0.0.1 unless you have a private DB network.
  • Do not allow 3306/tcp from 0.0.0.0/0.
  • Store passwords outside public Git repos; treat server.cfg as secret.

Managed hosting note

On Chapter22 game hosting, databases are often provisioned alongside the server—use the panel credentials rather than installing MariaDB yourself.



Frequently Asked Questions

Should FiveM connect as root?

No. Create a dedicated database user with rights only on the framework database.

Do I open 3306 in UFW for oxmysql?

Not when MariaDB runs on the same machine—use 127.0.0.1. Open 3306 only for tightly restricted remote administration.


Need help?

If you are stuck after following this guide, open a ticket from the Chapter22 client area with the exact error, the port or DNS change you made, and whether the service listens locally (ss / Resource Monitor) but fails externally.

Build the server. Grow the community. Start your next chapter.

Need a managed game server instead?

Run communities on Chapter22 game hosting.

If you want a panel, automatic installs, and support without babysitting a full VPS, start with Chapter22 game hosting.