Database and frameworks
FiveM Database and Frameworks
Most serious FiveM servers run a framework (ESX or QBCore) on top of a MySQL/MariaDB database. This guide covers installing the database, the two dominant frameworks, and the common resources nearly every server adds. Complete Setup, Configuration, and Running as a Service first.
Database Setup (MariaDB)
Most FiveM frameworks need MySQL or MariaDB. Install MariaDB on the same Windows machine:
- Download MariaDB Server from
mariadb.org. - Run the installer. Set a strong root password. Keep the default port (3306).
- Open HeidiSQL (bundled with MariaDB) and connect with root credentials.
- Create a database for your server: right-click in the panel, Create new > Database. Name it
fivem. - If using ESX or QBCore, import their SQL schema file (downloaded with the framework) into this database.
Connecting Resources to the Database
Your server resources connect via the oxmysql resource (modern) or the older mysql-async. The connection string in server.cfg looks like:
set mysql_connection_string "server=127.0.0.1;database=fivem;userid=root;password=YOUR_DB_PASSWORD"
Better practice: create a dedicated MySQL user with access only to the fivem database rather than using root. In HeidiSQL, go to Tools > User manager, create a user, and grant it privileges on the fivem database only.
Installing oxmysql
Most modern frameworks depend on oxmysql:
- Download the latest release from
github.com/overextended/oxmysql. - Extract into
C:\FXServer-data\resources\oxmysql\. - Add
ensure oxmysqlnear the top of yourserver.cfgresource list (before any framework that needs it). - Set the connection string as shown above.
Installing a Framework
The two dominant FiveM frameworks are ESX Legacy and QBCore. Both are GitHub-based, free, and well-documented. Pick one; they are not meant to run together.
ESX Legacy
- Navigate to your resources folder and clone the framework: ``
powershell cd C:\FXServer-data\resources git clone https://github.com/esx-framework/esx_legacy.git [esx_legacy]`` (The square brackets create a resource category folder, which FiveM uses for load ordering.) - Import the ESX SQL schema into your
fivemdatabase via HeidiSQL. - Read the README at the cloned repo for current install steps; they change between versions.
- In
server.cfg, ensure the resources load in the correct order (oxmysql first, then ESX core, then ESX-dependent resources).
QBCore
- Follow the install guide at
docs.qbcore.org. It is well-maintained and version-accurate. - QBCore uses
oxmysql; ensure that resource is installed and the connection string is set. - Import the QBCore SQL schema into your database.
These frameworks are deep ecosystems with their own job, vehicle, and inventory systems. Their official docs are the source of truth and change frequently, so always follow the live docs rather than a cached tutorial.
Load Order Matters
FiveM starts resources in the order their ensure lines appear in server.cfg. A typical framework load order:
ensure oxmysql
ensure es_extended # or qb-core
ensure esx_menu_default
ensure esx_menu_list
ensure esx_menu_dialog
# ... then job, shop, and other dependent resourcesIf a resource fails to load with a dependency error, it is almost always loading before something it needs. Move its ensure line further down.
Common Resources
Beyond a framework, most servers add:
| Resource | Purpose | Source |
|---|---|---|
| oxmysql | Database connector (dependency for most) | github.com/overextended/oxmysql |
| EasyAdmin | In-game admin tool | github.com/Brrocky/EasyAdmin |
| vMenu | All-in-one menu (admin + player) | github.com/TomGrobbe/vMenu |
| pma-voice | Built-in proximity voice chat | github.com/AvarianKnight/pma-voice |
| screenshot-basic | Screenshot capability for admin tools | FiveM forums |
| chat-theme | Cleaner chat UI | FiveM forums |
Install by cloning or extracting into C:\FXServer-data\resources\ and adding ensure resource_name in server.cfg.
Verifying the Database Connection
After starting the server with oxmysql and a framework, watch the console. A healthy connection logs something like:
[oxmysql] Database server connection established.
If you see connection refused or access denied:
- Confirm MariaDB is running (
Get-Service MariaDBin PowerShell) - Confirm the connection string credentials are correct
- Confirm the database name in the string matches the one you created
Common Issues
- "oxmysql was unable to connect": Wrong credentials or MariaDB is not running. Verify both.
- Framework loads but jobs/shops are missing: SQL schema was not imported. Re-import the framework's
.sqlfile into your database. - "attempted to load resource X before its dependency": Load order problem. Move the dependency's
ensureline higher inserver.cfg. - Database works but data does not persist: Some resources cache and only write on disconnect or scheduled save. Confirm the resource's save interval settings.
What to Read Next
- OneSync, Updates, and Backups for database backup procedures and scaling
- Running as a Service to keep everything running through reboots
- Official framework docs:
docs.esx-framework.organddocs.qbcore.org