Skip to main content

Link MySQL database to FiveM

This tutorial explains how to link your MySQL database to your FiveM server.

Prerequisites

Make sure you have installed one of the following MySQL connection scripts:

Installation

  1. Download the script of your choice
  2. Place it in your resources folder
  3. Add ensure oxmysql or ensure mysql-async to your server.cfg

Connection configuration

Open your server.cfg file and add the following connection string:

set mysql_connection_string "server=mysql.yorkhost.fr;uid=USERNAME;database=NAME_DATABASE;password=PASSWORD_DATABASE"
Automatic generator

Use our online generator to automatically create your SQL connection string.

Parameters to replace

ParameterDescriptionWhere to find it
USERNAMEUsernameDatabase tab on the panel
NAME_DATABASEDatabase nameDatabase tab on the panel
PASSWORD_DATABASEDatabase passwordDatabase tab on the panel

MySQL server address

Warning

The MySQL server address (server=) depends on your hosting plan. Check the address or IP provided in the Database tab on the WISP / Pterodactyl panel.

For a FiveM Intel plan, the address is usually: mysql.yorkhost.fr

Common issues

Password containing special characters

Passwords containing the = character may cause connection problems.

Solution:

  1. Go to the Database tab on your panel
  2. Click Reset password
  3. Repeat until you get a password without the = character

Connection error

If you get a connection error:

  • Check that all parameters are correct
  • Make sure the MySQL script is running (ensure oxmysql)
  • Verify that your database exists on the panel

Complete example

# Database connection
set mysql_connection_string "server=mysql.yorkhost.fr;uid=s1_myserver;database=s1_myserver;password=MyPassword123"

# Start MySQL script
ensure oxmysql

Best regards, the YorkHost team