Docs / Training: FiveM server (GTA V)
Connect a database
Install MariaDB and connect it to the server with oxmysql.
Training on GTA V: this page covers FiveM, the GTA V roleplay platform. No tool to create a GTA 6 server has been announced: what you learn here is the best preparation.
RP frameworks (ESX, QBCore, Qbox) store characters, money and inventories in a MySQL/MariaDB database. The most used connector is oxmysql.
1. Install MariaDB (Linux, Debian or Ubuntu)
sudo apt update
sudo apt install mariadb-server
sudo mysql_secure_installation
On Windows, install MariaDB from its official website, or use the database provided by your host.
2. Create the database and a user
CREATE DATABASE my_server CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'a_strong_password';
GRANT ALL PRIVILEGES ON my_server.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;
Keep the user limited to localhost if the database is on the same machine as the server.
3. Connect the server
In server.cfg, before the framework:
set mysql_connection_string "mysql://fivem:a_strong_password@localhost/my_server?charset=utf8mb4"
ensure oxmysql
4. Import the tables
Each framework ships a .sql file to import (txAdmin does it for you with the ESX and QBCore templates):
mysql -u fivem -p my_server < file.sql
Security: never open the database port (3306) to the Internet. If you need remote access, use an SSH tunnel.
Backups
Schedule a daily backup:
mysqldump -u fivem -p my_server > backup-$(date +%F).sql
Keep several days of backups, on another machine.
What about GTA 6?
A well-organised database (characters, money, inventories) is easier to migrate. To be confirmed: the database and connector used for GTA 6 are not known.
