Tutorial

oxmysql Setup for FiveM: Connection String Guide

How to install and configure oxmysql on a FiveM server: the mysql_connection_string, database creation, start order and the errors that block most scripts.

By ALN DEV · · 2 min read

Almost every modern FiveM framework and script saves data through oxmysql, the database resource maintained by Overextended. If it is not configured correctly, nothing that stores data will start. This guide gets it working.

What you need

  • A MySQL or MariaDB database server, local or from your host.
  • An empty database and a user with access to it.
  • The oxmysql resource in your resources folder.

Step 1: Create the database and user

Create a new empty database (for example fivem) with HeidiSQL, phpMyAdmin or your host's panel. Create a dedicated user with a strong password and give it access to that database only. Avoid using the root account on a live server.

Step 2: Add the connection string

Put this line near the top of server.cfg, before any resource is started, and replace the values with your own:

set mysql_connection_string "mysql://user:password@localhost/fivem?charset=utf8mb4"

The format is mysql://user:password@host/database. If your password contains special characters such as @ or #, encode them or change the password, because they break the URL.

Step 3: Start oxmysql first

ensure oxmysql
ensure ox_lib
ensure qb-core        # or es_extended / qbx_core

Everything that uses the database must start after oxmysql. Put it at the top of your resource list.

Step 4: Import the framework and script tables

Frameworks and many scripts ship .sql files. Import them into your database before the first start, as described in how to install a FiveM script.

Common errors

  • Access denied / cannot connect: wrong user, password or host. Test the same credentials in HeidiSQL first.
  • Unknown database: the database name in the string does not exist yet.
  • No such export: oxmysql is not running, or starts after the resource that needs it.
  • Table doesn't exist: the .sql file for that script was not imported.
  • Connection string missing: the set mysql_connection_string line is below the resources that need it, or has a typo.

Still getting errors on start? Follow the checklist in FiveM script not starting, or browse scripts that list their dependencies clearly.