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 — deprecated, replace it with oxmysql on a new server
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 "mysql://USERNAME:PASSWORD_DATABASE@mysql.yorkhost.fr/NAME_DATABASE?charset=utf8mb4"
Use our online generator to automatically create your SQL connection string.
Parameters to replace
| Parameter | Description | Where to find it |
|---|---|---|
USERNAME | Username | Databases tab on the panel |
NAME_DATABASE | Database name | Databases tab on the panel |
PASSWORD_DATABASE | Database password | Databases tab on the panel |
MySQL server address
The MySQL server address (the part after the @) depends on your hosting plan. Check the address or IP provided in the Databases tab on the YorkHost 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 Databases tab on your panel
- Click New password
- Repeat until you get a password without the
=character
The @, #, /, : or ? characters also break the mysql://… format. Instead of changing the password, you can use the key=value format:
set mysql_connection_string "host=HOST;port=3306;user=USER;password=PASSWORD;database=DATABASE"
More cases (error 1045, Connection From field, failing import): Database troubleshooting.
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 "mysql://s1_myserver:MyPassword123@mysql.yorkhost.fr/s1_myserver?charset=utf8mb4"
# Start MySQL script
ensure oxmysql
Best regards, the YorkHost team