How to Connect Your MySQL Database in FiveM
How to Connect Your MySQL Database in FiveM | EUGameHost
Connect your FiveM server to MySQL to store persistent data such as:
- player data
- money and bank balances
- inventories
- vehicles
- properties
- jobs and gangs
- character information
This is required for most frameworks such as QB-Core and ESX Legacy.
Difficulty: Intermediate
Time Required: 7 Minutes
Step 1: Create Your Database
Log in to your EUGameHost Game Panel.
Go to:
Databases
Click:
New Database
Enter a database name.
Example:
eugamehost_rp
Set Connection From to:
%
This allows your server to connect correctly.
Click create.
Step 2: Get Your Database Details
After creating the database, open its details.
Copy the following information:
Host
Username
Password
Database Name
Port
Example:
Host: mysql.eugamehost.com
Username: user123
Password: yourpassword
Database: eugamehost_rp
Port: 3306
Keep these details safe.
Step 3: Add the Connection String
Open your server.cfg file.
For modern servers using oxmysql, add:
set mysql_connection_string "mysql://USERNAME:PASSWORD@HOST:3306/DATABASE_NAME?charset=utf8mb4"
Replace each value with your actual database details.
Example:
set mysql_connection_string "mysql://user123:[email protected]:3306/eugamehost_rp?charset=utf8mb4"
Step 4: Ensure oxmysql Starts First
Make sure oxmysql is started before your framework.
Example:
ensure oxmysql
ensure qb-core
This is very important.
If the order is wrong, your framework may fail to load.
Step 5: Restart Your Server
Restart your server from the EUGameHost Game Panel.
Once restarted, your server should connect to the database automatically.
Common Issues
Database Connection Failed
Check that:
- username is correct
- password is correct
- host is correct
- database name matches
- port is
3306
Framework Not Loading
This is usually caused by load order.
Always make sure:
ensure oxmysql
loads before your framework.
Best Practice
Always use:
utf8mb4
This ensures proper support for special characters and emojis in names and text data.
Need Help?
If your database is not connecting, the EUGameHost support team can help you verify the connection details quickly.
Host Your FiveM Server from £4.20/Month
Ultra-low latency. Instant setup. 30Tbps Anycast DDoS protection.
Everything you need to run a stable, secure RP server.
Start Your Server Today