How to Set Up and Optimize MySQL for Your FiveM Server (2026)
Complete guide to setting up MySQL or MariaDB for FiveM — installing the database, configuring oxmysql, connection strings, database management tools, and optimization tips.
Why Your FiveM Server Needs a Database
Every FiveM roleplay server stores persistent data — player characters, inventories, vehicles, jobs, bank accounts, properties, and more. This data lives in a MySQL or MariaDB database that your server reads from and writes to constantly.
Getting your database set up correctly and optimized is one of the most important steps in building a reliable FiveM server in 2026.
MySQL vs MariaDB
Both work with FiveM:
- MySQL — The original, maintained by Oracle. Widely used and well-documented
- MariaDB — A community fork of MySQL, fully compatible. Often preferred for its open-source nature and performance improvements
Either choice works. MariaDB is slightly more common in the FiveM community because many VPS providers include it by default.
Installing the Database
On Windows (XAMPP)
The easiest way to get MySQL running on Windows for development:
- Download XAMPP from apachefriends.org
- Install it with MySQL selected
- Open the XAMPP Control Panel and start MySQL
- The database is now running on
localhost:3306
On Windows (Standalone MariaDB)
For production or dedicated servers:
- Download MariaDB from mariadb.org
- Run the installer and set a root password
- MariaDB runs as a Windows service automatically
On Linux (Ubuntu/Debian)
sudo apt update
sudo apt install mariadb-server
sudo mysql_secure_installation
The mysql_secure_installation script sets a root password and removes test databases.
Creating Your FiveM Database
Once MySQL/MariaDB is running, create a database for your server:
- Open a database management tool (HeidiSQL, DBeaver, or phpMyAdmin)
- Connect to your database server (
localhost:3306with root credentials) - Create a new database — Common names are
fivem,es_extended, orqbcore - Create a dedicated user for your FiveM server (don't use root in production)
- Grant the user full permissions on the FiveM database
Installing oxmysql
oxmysql is the standard database connector for FiveM in 2026. It replaces older alternatives like mysql-async and ghmattimysql:
- Download oxmysql from its GitHub releases page
- Place it in your
resources/folder - Add
ensure oxmysqlto your server.cfg — this must come before your framework - Configure the connection string
Connection String Format
Add this to your server.cfg:
set mysql_connection_string "mysql://username:password@localhost/database_name?charset=utf8mb4"
Replace:
username— Your database userpassword— The user's passwordlocalhost— The database host (uselocalhostif on the same machine)database_name— The name of your FiveM database
Connection String Tips
- Special characters in passwords — If your password contains special characters like
@or#, URL-encode them - Remote databases — Replace
localhostwith the database server's IP address - Custom port — Add the port after the host:
localhost:3307
Database Management Tools
HeidiSQL (Windows)
Free, lightweight, and popular in the FiveM community:
- Visual table browser and editor
- Query execution with syntax highlighting
- Export and import functionality
- Available at heidisql.com
DBeaver (Cross-platform)
More powerful, supports multiple database types:
- Advanced query editor
- ER diagrams and table visualization
- Community edition is free
phpMyAdmin (Web-based)
Runs in your browser, typically included with hosting panels:
- No installation needed if using a hosting panel
- Intuitive for basic operations
- Comes with XAMPP
Importing Framework Tables
After connecting your FiveM server to the database, your framework needs its tables created:
- ESX Legacy — Import the SQL file included in the es_extended resource
- QBCore — Import the SQL file from qb-core
- QBOX Core — Follow the QBOX documentation for database setup
Most scripts also include SQL files that add their own tables. Always import these before starting the server with a new resource.
Optimization Tips
Buffer Pool Size
The most impactful MySQL setting for FiveM:
innodb_buffer_pool_size = 512M
This caches frequently accessed data in memory. Set it to 50-70% of available RAM on a dedicated database server, or 256M-512M on a shared server.
Connection Limits
max_connections = 150
FiveM resources can open many simultaneous connections. Set this high enough to avoid "too many connections" errors.
Regular Maintenance
- Back up daily — Use
mysqldumpor your management tool's export feature - Clean old data — Remove stale player records and old logs periodically
- Monitor slow queries — Enable the slow query log to find problematic queries
Common Issues
"Connection refused"
- Verify MySQL/MariaDB is running
- Check the port (default 3306)
- Confirm the user has permission to connect from the server's IP
"Access denied"
- Double-check username and password in the connection string
- Verify the user has grants on the correct database
"Table doesn't exist"
- Import the required SQL files for your framework and resources
- Check that you're connected to the correct database
A Solid Database Foundation
A properly configured database is invisible — it just works. Combined with well-built scripts like Jobs Creator that use efficient async queries, your server's data layer will handle anything your players throw at it.
Ready to Transform Your Server?
FiveM Job Creator eliminates every problem discussed in this article. 0.00ms resmon. No-code configuration. ESX & QBCore native.
Get Job Creator on Tebex — €29.99