QBCore, ESX and Qbox store players, inventories and vehicles in a MySQL/MariaDB database. You install it once, on the same VPS, and FiveM connects through localhost.
Windows
- Download the MariaDB MSI installer (an LTS version) from
mariadb.org/download. - Install it and set a long root password. Keep Install as service ticked so it starts with Windows.
- The installer includes HeidiSQL, a program to view and edit the database with windows.
Linux (Ubuntu / Debian)
apt install -y mariadb-server
mariadb-secure-installation
Answer the questions: remove anonymous users and the test database.
Create the database and its user
Do not use root for FiveM. Open MariaDB (on Windows, from HeidiSQL or with mysql -u root -p; on Linux, with mariadb) and run:
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;
Those are the details txAdmin asks for when deploying the recipe: database fivem, user fivem and its password.
The connection string (oxmysql)
txAdmin writes it into your server.cfg. If you set it by hand, it looks like this:
set mysql_connection_string "mysql://fivem:A_LONG_PASSWORD@localhost/fivem?charset=utf8mb4"
ensure oxmysql must come before the framework in the load order. If your password contains symbols such as @ or #, change it for one without them: they break the string.
Do not open port 3306
The database is only used by the FiveM server on the same machine. Opening 3306 to the internet invites attacks. To manage it from your PC, use HeidiSQL with its SSH tunnel option (on Linux) or connect over remote desktop (on Windows).
The two most common errors
| Console error | What it means |
|---|---|
ECONNREFUSED 127.0.0.1:3306 | MariaDB is not running. On Windows, check the service in services.msc; on Linux, systemctl status mariadb. |
Access denied for user | User, password or database name mistyped in the connection string. |
And take backups: the daily database dump is what saves you if a script wipes the inventories.