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:
- oxmysql (recommended): https://github.com/overextended/oxmysql
- mysql-async: https://github.com/brouznouf/fivem-mysql-async
Installation
- Download the script of your choice
- Place it in your
resourcesfolder - Add
ensure oxmysqlorensure mysql-asyncto yourserver.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
| Parameter | Description | Where to find it |
|---|---|---|
USERNAME | Username | Database tab on the panel |
NAME_DATABASE | Database name | Database tab on the panel |
PASSWORD_DATABASE | Database password | Database 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:
- Go to the Database tab on your panel
- Click Reset password
- 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