Connect FXServer to MariaDB or MySQL
oxmysql connects FiveM resources to MariaDB/MySQL. A PostgreSQL URL in mysql_connection_string does not make oxmysql a PostgreSQL driver. Use the database and migrations required by the exact framework/resource version; do not switch an existing server’s database engine based on a generic guide.
Prepare an isolated database
Use a dedicated database and application account with access only to the intended schema. Keep port 3306 private to FXServer’s host/application network. On a host where MariaDB is already managed, use its normal backup and account-provisioning workflow. Do not copy a root account or an example password into production.
Install the framework’s matching schema/migrations only after backing up an existing database. The example in database integration uses its own docs_db_probe table; it is not an ESX /QBCore schema.
Set the connection before starting resources
Install a reviewed oxmysql release as resources/[standalone]/oxmysql. In the active server configuration, replace the example credentials and database:
set mysql_connection_string "mysql://fivem_user:[email protected]:3306/fivem?charset=utf8mb4"
ensure oxmysql
ensure docs_db_probeThis is a template, not a working secret. Follow the upstream connection-format restrictions when credentials contain reserved characters. Use set, not sets or setr, for the secret connection string. Do not print it in screenshots or shared logs.
127.0.0.1 means the network namespace of FXServer. If the database is in another container or host, use the private address/service name reachable from FXServer, not the browser’s localhost. A successful connection on your laptop does not test the game server’s route.
Verify the database path
From a host/container with the same database reachability as FXServer, use an installed SQL client and let it prompt for the password:
mariadb --host=127.0.0.1 --port=3306 --user=fivem_user --password fivem -e 'SELECT 1'A returned 1 verifies this account’s connection to that database. It does not verify framework tables or oxmysql initialization. Next start oxmysql and run the complete server-only integration example. Its manifest loads @oxmysql/lib/MySQL.lua before the consumer script; a dependency alone does not create the MySQL global.
Diagnose the first error
| Error or observation | Check next |
|---|---|
| Connection refused/timeout | Listener, private host/port, firewall and FXServer container routing |
| Access denied | Actual account/password and allowed connection host; do not broaden grants to everyone |
| Unknown database/table/column | Correct schema and migration revision, not an unrelated dump |
MySQL is nil in a Lua resource | Server-only wrapper import and script order in that resource’s manifest |
| Query is slow | Query plan/indexes, matching server timeline and startup versus steady-state load |
The upstream mysql_slow_query_warning convar sets a diagnostic threshold in milliseconds; it is not a universal performance target. Query debugging can expose player data and parameters. Enable it only deliberately in a controlled environment and remove sensitive logs before sharing.
For integration, parameter binding and rollback tests, continue with oxmysql Lua examples. For resource order, use resource lifecycle; for symptoms, use common errors.