MySQL database troubleshooting (FiveM)
This guide covers the most common reasons why a database does not connect, or a SQL import fails, on a FiveM server. For the initial setup, see Create a database and Link the MySQL database to FiveM.
Deleting a database erases all its tables and data. Before any deletion or re-creation, export it from phpMyAdmin (Export tab, SQL format) and keep the .sql file on your PC.
1. Use the pre-generated connection string
The Databases tab of the panel shows, for each database, a connection string ready to paste in oxmysql (FiveM) format, password included. It is the most reliable source: copy it as is into your server.cfg instead of rebuilding the line by hand.
set mysql_connection_string "…string copied from the Databases tab…"
After each change to server.cfg, fully stop and then start the server.
2. Password with special characters (error 1045)
Error 1045 (Access denied) means the MySQL server rejects the credentials. If the password contains special characters (@, #, /, :, ?…), they break the mysql://… format. Use the key=value format instead, which does not have this problem:
set mysql_connection_string "host=HOST;port=3306;user=USER;password=PASSWORD;database=DATABASE"
Replace HOST, USER, PASSWORD and DATABASE with the values shown in the Databases tab. The MySQL port is 3306.
Also check that the database name in your server.cfg is exactly the one shown in the panel: a single typo in this name is enough to prevent the connection.
3. The "Connection From" field at creation
When creating a database, leave the Connection From field empty (or %). Any other value restricts connections to a single address and your FiveM server is refused.
If the database was created with a wrong value, it has to be recreated: export it first (see the box at the top of the page), delete it, recreate it with an empty Connection From, re-import your export, then update the connection string (the password changes).
4. Use oxmysql, not mysql-async
mysql-async has been deprecated for a long time. Use oxmysql: it is the resource expected by recent frameworks (ESX, QBCore, ox_inventory…). A "dependency oxmysql not found" error means oxmysql is not installed (or its folder is misnamed) in resources/. For an unexplained error, start by updating oxmysql.
5. SQL import: remove CREATE DATABASE
A dump containing a CREATE DATABASE … line (often followed by USE …) fails to import: the database already exists in the panel. Delete these lines from the .sql file, select your database in phpMyAdmin, then run the import again. See Import and compress a SQL file.
6. "ALL PRIVILEGES" is not granted
ALL PRIVILEGES corresponds to administration rights on the database server: it is not granted. It is not needed: when a database is created from the panel, your user receives every right a FiveM server needs (read, write, create and alter tables…). A script that requires ALL PRIVILEGES or GRANT must be adapted.
7. Database hosted on MySQL-PROTECTED-01
A game server's databases should be on a MySQL-GAME server (for example MySQL-GAME-01 or MySQL-GAME-02). If the Databases tab shows your database on MySQL-PROTECTED-01 and the connection fails despite a correct string, recreate the database on a MySQL-GAME server if the choice is offered (after exporting it); otherwise, open a ticket: the team will move it for you.
Summary
| Symptom | Likely cause | Fix |
|---|---|---|
| Error 1045 / Access denied | Password with special characters, wrong database name | host=…;port=3306;user=…;password=…;database=… format, check the name |
| Connection refused despite a correct string | Connection From field filled in | Export, recreate the database with the field empty |
| Import failing on the first line | CREATE DATABASE / USE in the dump | Remove these lines |
| "oxmysql not found" | Resource missing or misnamed | Install / update oxmysql |
Script requiring ALL PRIVILEGES | Right not granted | Adapt the script |
Support
If the error persists, open a ticket with the exact console error (without the password) and the database name as shown in the panel.