Published on · last updated on
What the database is responsible for
A clean separation helps understanding - and later the migration:
- The
resourcesfolder holds the behavior: scripts, vehicles, MLOs, menus. Everything that is programmed or downloaded. - The database holds the state: which player has which job, how much money is in the account, who owns which vehicle.
If you delete a resource, a feature disappears. If you delete the database, the entire history of your server disappears. That is why it is the part you treat most carefully.
FiveM server hosting from €7.99 / month
Prepaid without a contract, DDoS protection up to 250 Gbit/s.
View plans & pricesLogin details and phpMyAdmin
Your database has already been created. You find the login details - host, database name, user and password - in our game server panel. From there, you also open phpMyAdmin directly in the browser.
phpMyAdmin is your tool for everything that does not happen in the game: viewing tables, correcting individual records, importing your framework's .sql files and regularly taking an export as a backup. You do not need any additional program on your own computer for this.
Connection in the server.cfg
The server does not talk to MySQL directly but via a connector - today usually oxmysql. It receives its login details as a connection string in the server.cfg:
set mysql_connection_string "mysql://user:password@host/database?charset=utf8mb4"
Two things matter here. First, this line belongs before the first ensure line - the connector starts first, everything else builds on it. Second, utf8mb4 belongs at the end: without the character set, accented letters and emojis in character names or chat messages get mangled.
If your password contains special characters that have a meaning in a URL, they need to be encoded. If you want to avoid that, choose a password without @, : and /.
Import SQL files
Frameworks and many scripts come with .sql files that create their tables. Without this step, the server starts, but nobody can create a character or buy a vehicle.
- Select the database on the left in phpMyAdmin.
- Switch to "Import" at the top.
- Select the
.sqlfile and run it.
With large files, the upload limit kicks in. Two ways out: upload the file compressed - phpMyAdmin accepts .sql.gz and .zip directly - or split the import into several smaller files. Import the files in the order your framework specifies: first the core, then the modules, then the additional scripts. What this stack looks like is shown in set up ESX and set up QBCore.
Backups - your job, your advantage
Automatic backups are deliberately not part of the plan with us. In return, you can take a complete export yourself at any time: in phpMyAdmin, click "Export", choose quick export, done - one file that contains the complete state of your server.
Sensible moments for an export are always the same: before every larger script update, before importing someone else's .sql and at regular intervals during normal operation. A script that restructures tables during an update is installed quickly - and cannot be undone without an export.
Keep the exports outside the server. A backup that sits on the same system as the original is not a backup.
When the connection does not work
Database errors show up unmistakably in the live console, usually right at startup. The causes are almost always the same:
- Typo in the connection string. One missing character is enough. Copy the details from the panel instead of typing them.
- Connector starts too late. If its
ensureline comes after the framework, the core finds no connection at startup. - Tables missing. The server runs, but every action fails - then the
.sqlwas not imported, or only partially. - Two connectors. An old script brings its own; then two of them fight over the same task. Decide on one.
If the server becomes sluggish under load even though the connection works, it is worth looking at the queries: a database that is asked at every step a player takes is a common brake. How to measure that is explained in improve server performance.
Frequently asked questions
Rent a FiveM server with a database
MySQL database including phpMyAdmin in every plan, full access to resources and server.cfg - prepaid without a notice period, located in Frankfurt am Main.
View plans & pricesFiveM server hosting
from €7.99 / month
Prepaid without a contract, DDoS protection up to 250 Gbit/s, hosted in Frankfurt am Main.
View plans & pricesRead more
- FiveM server - overview
- server.cfg explained
- Set up an ESX server
- Set up a QBCore server
- Move a FiveM server
- Install resources
- Improve server performance
Discover more