Back to Blog
Server Setup 9 min read November 2, 2024

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.

fivem mysql oxmysql fivem database mariadb fivem setup

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:

  1. Download XAMPP from apachefriends.org
  2. Install it with MySQL selected
  3. Open the XAMPP Control Panel and start MySQL
  4. The database is now running on localhost:3306

On Windows (Standalone MariaDB)

For production or dedicated servers:

  1. Download MariaDB from mariadb.org
  2. Run the installer and set a root password
  3. 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:

  1. Open a database management tool (HeidiSQL, DBeaver, or phpMyAdmin)
  2. Connect to your database server (localhost:3306 with root credentials)
  3. Create a new database — Common names are fivem, es_extended, or qbcore
  4. Create a dedicated user for your FiveM server (don't use root in production)
  5. 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:

  1. Download oxmysql from its GitHub releases page
  2. Place it in your resources/ folder
  3. Add ensure oxmysql to your server.cfg — this must come before your framework
  4. 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 user
  • password — The user's password
  • localhost — The database host (use localhost if 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 localhost with 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 mysqldump or 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.

→ Browse Premium FiveM Scripts at Alone Studios

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