Skip to content

FiveM

FiveM MariaDB Setup and Slow Query Diagnosis

Connect a framework to a private database, separate runtime from migration permissions and trace slow queries without exposing player data.

FiveMMariaDBDatabaseoxmysqlSQLSlow queries
Reading time
4 min read
Published
Updated
Maintained by
EnderHost Team

Set up a FiveM database by installing a supported MariaDB release, creating a dedicated application schema and account, importing the framework’s reviewed schema and configuring its supported connector before dependent resources start. Keep database access private. When queries are slow, correlate application timing with database evidence rather than assuming every connector warning means the database hardware is inadequate.

Choose versions from the framework requirements

Confirm the framework/resource releases and their supported database connector before installation. Overextended’s documentation describes the original project’s discontinuation and subsequent community maintenance; record the actual repository and release you use instead of assuming an old download remains maintained. Check the framework’s current guidance for that combination.

1. Provision a private database

  1. Install MariaDB through its supported operating-system procedure or use an appropriate managed database.
  2. Bind to local/private connectivity where possible and permit only the application hosts that need access. Do not expose the database publicly to simplify a connection test.
  3. Create the application schema with the character set/collation expected by the framework.
  4. Create a dedicated runtime account scoped to that schema and connection source. Grant the operations the application needs; use a separately controlled migration account if broader schema changes are required.
  5. Record versions and recovery credentials securely, then take a baseline backup before importing custom data.

Account identity can include the connection host. A user that works through a local socket may not match a TCP connection from another host. Test the same endpoint and transport that the connector will use before changing firewall or grants.

2. Configure startup order and credentials

For a compatible oxmysql deployment, set the connection string before starting the connector and start it before framework resources. Use the format supported by the installed release. Do not place the connection string in a replicated or public server-information variable, and do not copy an example root account into production.

# server.cfg: placeholders only; use your connector-supported secret format
set mysql_connection_string "user=APP_USER;password=APP_SECRET;host=127.0.0.1;port=3306;database=APP_DATABASE"
ensure oxmysql
# Start the selected framework and dependent resources afterward.

Special characters need the connector’s documented handling for the chosen format. Keep this configuration out of public source control and redact it from support logs. Import installation SQL once into a test schema first; understand whether a migration deletes, overwrites or transforms existing records.

3. Verify persistence, not only connectivity

  1. Start privately and inspect connector/framework errors.
  2. Create a test character or another supported application record.
  3. Save, disconnect and restart cleanly, then confirm the same state loads.
  4. Take a matched file/database backup and rehearse restoring it into an isolated target before relying on scheduled backups.

How to investigate a slow-query warning

Separate the possible causes
EvidenceNext investigation
One query pattern is repeatedly slowExecution plan, filters, joins, indexes and result size
Many unrelated queries slow togetherConnections, lock waits, storage latency and host load
Only startup is slowMigrations, cold caches and resource initialization
Warnings align with FXServer hitchesApplication scheduling and the server profile alongside database timing

Enable a bounded slow-query logging interval using the variable names for your MariaDB version. Record the previous settings and restore them afterward. Logs may contain player identifiers or values; restrict access and retention. Avoid enabling unbounded full-query logging on a busy production server.

Use EXPLAIN to inspect a representative statement’s planned access path. Runtime analysis variants can execute the statement, so understand the exact command before using it, especially with writes. Test index or query changes against representative data and preserve result correctness; a faster incorrect query is not an improvement.

Use FiveM recovery before schema changes and hitch diagnostics for correlated server work. Compare FiveM hosting with database access, location and recovery needs included.

Sources and references

Hosting documentation. Publication and update dates reflect this edition.

Related articles

Related topics

Hardware we trust. Software you know.

PREPARING YOUR EXPERIENCE