Skip to content
FIVECRATE

oxmysql Setup: mysql_connection_string Explained

Set mysql_connection_string for oxmysql 2.14.3: both formats, password characters, set vs setr, pool options, slow query warnings, debug convars and fixes.

Author: FiveCrate
Published:
Updated:
Read time: 22 min
Applies to
FiveM Legacy and FiveM for GTAV Enhanced; oxmysql 2.14.3 (October 6, 2026) with mysql2 3.24.5, which requires FXServer 12913 or newer; the Qbox, ESX Legacy, StreetKings and WarfareTacticsV txAdmin recipes (November 2026), existing QBCore servers and any other resource that uses oxmysql; MariaDB or MySQL on Windows and Linux
Last verified

Direct Answer

mysql_connection_string is the convar that tells oxmysql how to log in to your MariaDB or MySQL server. Add it to server.cfg with set, never setr or sets, above your ensure lines, and start oxmysql before every resource that uses it. Write it as mysql://user:password@host:port/database or as user=...;password=...;host=...;port=...;database=.... If the password contains reserved characters such as : / ? # ; =, change the password or switch to the other format, because oxmysql does not decode URL escapes. oxmysql reads the line only when it starts, so restart the server after every edit.

What mysql_connection_string does in oxmysql

oxmysql is the resource that connects FXServer to a MySQL or MariaDB database through the node-mysql2 library. Its documentation calls it a replacement of mysql-async and ghmattimysql, and its manifest declares that it provides both, so it can take their place once you delete them. Qbox’s qbx_core, ESX’s es_extended and QBCore’s qb-core all list oxmysql as a dependency, so the connection line works the same way on all three frameworks.

When oxmysql 2.14.3 starts, it looks for its login in three places, in this order:

  1. The mysql_connection_string convar from your config.
  2. An environment variable named DB_CONNECTION in the FXServer process.
  3. The built-in fallback mysql://root@localhost: user root, no password, no database.

The fallback explains a confusing log. A server with no connection line, or with a misspelled convar name, tries to log in as root without a password.

oxmysql then turns the string into mysql2 options and creates one connection pool that every resource shares. When the pool works, the console prints the database server’s version in square brackets followed by Database server connection established!. When it fails, oxmysql prints Unable to establish a connection to the database with the error code in parentheses, a link to its common issues page (issue 154 on GitHub) and the settings it tried, with the password shown as ******. It tries again every 30 seconds until a connection succeeds.

Everything on this page applies to FiveM Legacy and FiveM for GTAV Enhanced alike. txAdmin’s Legacy recipe index (indexv4.json) and its Enhanced index (indexv5.json) point to the same Qbox and ESX Legacy recipes, both of which download oxmysql, and the StreetKings and WarfareTacticsV game-mode recipes download it too. Cfx.re’s page on what changed in Enhanced says nothing about databases or Node.js resources. oxmysql 2.14.3, released on October 6, 2026 with mysql2 3.24.5, declares Node.js 22 and the dependency /server:12913 in its manifest, which Cfx.re’s manifest reference reads as a requirement of “at least server build” 12913.

The two mysql_connection_string formats

The oxmysql documentation shows both formats side by side, with the comment “Use your preferred format”:

set mysql_connection_string "mysql://root:12345@localhost:3306/fivem"
set mysql_connection_string "user=root;password=12345;host=localhost;port=3306;database=fivem"

Both lines carry the same five values: user root, password 12345, host localhost, port 3306 and database fivem. Replace each one with your own and keep the quotation marks around the whole value, as every official example does.

URI format: mysql://user:password@host:port/database

oxmysql treats the value as a URI only when it contains mysql://. Use that prefix for MariaDB too: a value that starts with mariadb:// is read as the key-value format, and none of its parts reach mysql2.

  • Port: optional. Without it, mysql2 connects to port 3306, whatever port your database host gave you. The Qbox migration guide writes a non-default port after the host, as in localhost:3307.
  • Host: localhost for a database on the same machine, otherwise that machine’s address. Qbox’s remote access article notes that MariaDB “only listens on localhost (127.0.0.1)” by default, and says never to open port 3306 to the entire internet: allow only the fixed address of each machine that needs it. The FiveM database setup guide covers accounts and remote access in full.
  • Options: a ? after the database name starts a list of extra options joined with &, such as ?charset=utf8mb4.
  • No password: leave out the colon as well. The Qbox migration guide notes that the login part then “looks like root@localhost”.

txAdmin’s Recipe Deployer writes this format. It builds mysql://user:password@host/database?charset=utf8mb4 from the database fields you fill in, adds :port after the host only when the port is not 3306, and drops :password when the password field is empty. The Qbox migration guide shows a typical result, mysql://root:YourPassword@localhost/qbcore_a1b2c3?charset=utf8mb4, where the user is root, the password is YourPassword and the database is qbcore_a1b2c3.

Key-value format: user=…;password=…;host=…

Pairs are separated by ;, and each key is separated from its value by =. Before it splits the pairs, oxmysql renames a few alternative key names:

You can writeoxmysql reads it as
hostname, ip, server, data source, datasource, addr, addresshost
user, user id, userid, username, user name, uiduser
pwd, passpassword
dbdatabase

These names match in any letter case. Every other key is passed on exactly as written, and mysql2 accepts only its own spelling of each option name. Server=, User=, Uid= and Pwd= therefore work, but Password=, Host=, Port= and Database= do not: mysql2 skips them with the warning Ignoring invalid configuration option passed to Connection. A string copied from another program in the style Server=...;Database=...;Uid=...;Pwd=... loses its database name this way. Write the login keys in lower case: host, port, user, password and database.

oxmysql does not trim spaces either. In user=root; password=12345, the second key is password with a leading space, which mysql2 skips like any other unknown name, so the login goes out without a password. Put nothing between a ; and the next key.

The documentation does not rank the two formats. What separates them in practice is which password characters each one survives.

Special characters in the mysql_connection_string password

The oxmysql documentation warns that “certain special characters are reserved or unsupported depending on your connection string”, lists ; , / ? : @ & = + $ # and advises avoiding them or swapping the connection string format. The parser in oxmysql 2.14.3 (src/config.ts) shows what happens to the characters that break a login most often:

Character in the passwordURI formatKey-value format
:The password is cut off at the colonPassed on by the parser
/ or ?The login part is no longer recognised, so user, password, host and database come out wrongPassed on by the parser
#oxmysql stops with mysql_connection_string structure was invalidPassed on by the parser
; or =Passed on by the parserThe password is cut off at that character
%40 and other URL escapesSent as typed, not decodedSent as typed

Three consequences follow from the code:

  • URL-encoding does not help. mysql2’s own URL parser decodes escapes such as %40, but oxmysql reads the value with its own parser and hands the password to mysql2 exactly as written.
  • The txAdmin deployer does not escape the password either. It inserts the password you typed straight into the URI, so a password containing : or / produces a connection string that fails from the first start. The deployer’s own database test still passes, because it logs in with the separate host, port, user and password fields rather than the URI.
  • The simplest fix is a password without any of the listed characters. If the password has to stay, rewrite the line in the other format, as the documentation suggests.

oxmysql setup: where mysql_connection_string goes in server.cfg

  1. Open the config file your server starts with. That is normally server.cfg in the server data folder; Cfx.re’s command reference describes the usual start as FXServer.exe +exec server.cfg.

  2. Put the line above every ensure and start line. The oxmysql documentation says to set the connection string “before starting any resources”. The official Qbox and ESX Legacy recipes keep it in the first block of settings, next to the license key and slot count:

    sv_licenseKey "{{svLicense}}"
    sv_maxclients {{maxClients}}
    set mysql_connection_string "{{dbConnectionString}}"

    txAdmin populates dbConnectionString from the database fields you enter, then replaces every variable in server.cfg at the end of the deployment.

  3. Use set, never setr or sets. The documentation’s own words are “Make sure you only ever use set.” Cfx.re’s convar reference explains the difference:

    • set creates a standard convar, and standard convars “can only be used in server-side scripts”.
    • setr makes the value “available on the client side”, so client scripts could read your database password.
    • sets shows the name and value “on the server list” and exposes them in the server’s info.json file.
  4. Start oxmysql before the resources that use it. The documentation says to add start oxmysql to the top of the resource list, and the common issues page says it should be “the first resource in your resource start order”. The ESX Legacy recipe starts it right after the chat resource:

    ## Starting Default & Standalone Resources
    ensure chat
    ensure oxmysql
    ensure esx_lib

    ensure starts a resource that is not running and restarts one that is, so either command works here. The Qbox recipe has no line of its own for oxmysql: it unpacks oxmysql into resources/[ox], which starts after ensure qbx_core, and qbx_core lists oxmysql under dependencies, which Cfx.re’s manifest reference defines as resources that must “load before the current resource”. es_extended and qb-core declare the same dependency.

  5. Restart the server and read the console. Look for Database server connection established!. To see the value FXServer actually holds, type mysql_connection_string into the server console: Cfx.re’s reference says typing a convar’s name prints its value. That output includes your password, so never paste it into a public channel.

The line can also live in a separate file that server.cfg loads with exec, which runs the commands of another config file. The Qbox recipe loads ox.cfg and voice.cfg this way. Keep that exec line above the first ensure, so the convar exists before any resource starts.

oxmysql connection string options beyond the login

oxmysql passes every extra key in the value to mysql2 as an option. In the URI format, options go after ? and are joined with &. In the key-value format, they are simply more key=value pairs. oxmysql also sets a few options of its own: connectTimeout of 60000 ms (mysql2 alone waits 10 seconds), and supportBigNumbers and jsonStrings turned on. A value in your string replaces these defaults.

Every value arrives as text, and mysql2 reads an on/off option as on whenever it holds any text, the word false included. multipleStatements=false therefore turns multiple statements on, and supportBigNumbers=false or waitForConnections=false changes nothing. To keep an option off, leave it out of the string. The one exception is namedPlaceholders=false, which oxmysql checks for itself, as text.

OptionDefaultWhat it does
port3306TCP port of the database server
charsetmysql2 uses UTF8MB4_UNICODE_CI; txAdmin writes utf8mb4The charset for the connection; for a charset such as utf8mb4, its default collation is used. An unknown name stops mysql2 with Unknown charset
connectTimeout60000 ms (set by oxmysql)Milliseconds before the first connection to the server times out
sslOffEncrypts the connection. mysqljs defines it as an “object with ssl parameters or a string containing name of ssl profile”. oxmysql parses the value as JSON and prints Failed to parse property ssl in configuration if it is not valid JSON. ssl=true becomes the JSON value true, which mysql2 refuses with SSL profile must be an object. In an object, mysql2 sets rejectUnauthorized to true unless you set it to false
multipleStatementsOffAllows several statements in one query. oxmysql’s common issues page says it is disabled “to prevent easy SQL injection” and strongly suggests leaving it off
decimalNumbersOffReturns DECIMAL columns as numbers instead of strings, which the common issues page warns “may result in loss of precision”
namedPlaceholdersOnfalse turns off oxmysql’s handling of named placeholders, which its documentation marks as deprecated

mysql2 ignores any option name it does not know and prints a warning, covered under Troubleshooting.

oxmysql connection pool settings

oxmysql creates its pool with mysql2’s createPool and adds no pool option of its own, so mysql2’s defaults apply until your string overrides them. A pool keeps connections open and reuses them, which mysql2 says cuts “the time spent connecting”, and it opens connections “on demand until the connection limit is reached”.

Pool optionmysql2 defaultMeaning
connectionLimit10The maximum number of connections to create at once
maxIdleSame as connectionLimitThe most idle connections the pool keeps
idleTimeout60000 msHow long an idle connection is kept
queueLimit0Requests the pool queues before returning an error; 0 means no limit
waitForConnectionstrueWith every connection busy, true queues the request and false returns an error at once. The text false in the string still counts as true

The meanings of connectionLimit, queueLimit and waitForConnections come from the README of mysqljs, the library mysql2 says it is “mostly API compatible with”. mysql2 also lists enableKeepAlive: true and keepAliveInitialDelay: 0 among its pool defaults. With these defaults, a query that finds all ten connections busy waits in an unlimited queue instead of failing.

To change a pool option, add it like any other option. mysql2 converts the text to a number with Number():

set mysql_connection_string "mysql://root:12345@localhost:3306/fivem?connectionLimit=20"
set mysql_connection_string "user=root;password=12345;host=localhost;port=3306;database=fivem;connectionLimit=20"

The 20 is only an example. Neither the oxmysql nor the mysql2 documentation recommends a pool size. The hard limit sits on the database side: MariaDB’s max_connections caps simultaneous client connections at 151 by default, and its error 1040 reads Too many connections. Every open connection to the database server counts against that cap, including those of other FXServer instances and of tools such as HeidiSQL.

Slow query warnings: mysql_slow_query_warning

oxmysql warns in the console when a query takes long. The message has the form <resource> took <time>ms to execute a query!, starts with the database version in square brackets, and is followed by the query and its parameters. It appears once a query takes as long as the threshold or longer. The documentation sets the threshold like this:

set mysql_slow_query_warning 150

The official sources disagree on the default. The oxmysql 2.14.3 code reads the convar with a default of 200 ms. The debug UI page says “default 150ms”, and the main documentation page uses 150 in its example. If you rely on a particular threshold, set it explicitly.

The documentation adds three cautions about these warnings:

  • Query time “may not be entirely accurate”.
  • A slow query may not mean a database problem, for example during server hitches. If warnings arrive together with hitch messages, start with the server thread hitch warning guide.
  • Slow queries during server startup “are not necessarily problematic”.

oxmysql re-reads mysql_slow_query_warning, mysql_debug, mysql_ui and mysql_log_size every second. Changes to them from the server console apply without a restart. The connection string and the isolation level are read once, when oxmysql starts.

Debugging queries: mysql_debug, oxmysql_debug and the debug UI

mysql_debug prints every query to the server console. The documentation shows two forms, one for all resources and one limited to a list:

set mysql_debug true
set mysql_debug [
 "ox_core",
 "ox_inventory"
]

oxmysql reads the value false as off and parses anything else as JSON. A value that is not valid JSON turns debugging on for every resource, so a bare name such as set mysql_debug ox_core logs all of them.

While the server runs, oxmysql_debug add <resource> and oxmysql_debug remove <resource> change the list. Both work only from the server console, which oxmysql enforces with the message “This command can only be run server side”. If mysql_debug is true, add replaces it with a list that holds only that resource. The 2.5.0 release notes call these changes “not persistent”. In 2.14.3, the commands write the new list into the mysql_debug convar with SetConvar, so it survives a restart of oxmysql, but nothing is written to server.cfg: the next server start uses the list in your config again.

While mysql_debug is on, oxmysql asks the database’s own profiler for query times. A database that lacks it triggers a one-time warning ending in “Falling back to basic query timing.”

The debug UI shows the queries each resource ran, their response times and per-resource totals. To use it:

  1. Add set mysql_ui true to server.cfg. mysql_debug does not need to be on.
  2. Give your admin group the command or command.mysql ACE. The ESX Legacy recipe already grants group.admin every command with add_ace group.admin command allow. The ACE permissions guide explains the syntax.
  3. Type mysql in game. From the server console, the command only answers “This command cannot run server side”, and with mysql_ui off it does nothing at all.

The documentation says to enable the UI “only” during development or with a small player count, and points larger servers to the database’s built-in logging. While mysql_ui is on, oxmysql keeps up to mysql_log_size queries per resource in memory: 100 by default, or 10000 while mysql_debug is on. Queries above the slow query threshold appear in orange.

oxmysql convar reference (version 2.14.3)

ConvarDefault in the 2.14.3 codeReadPurpose
mysql_connection_stringEmpty, then DB_CONNECTION, then mysql://root@localhostAt startThe database login and options
mysql_slow_query_warning200Every secondThreshold in milliseconds for slow query warnings
mysql_debugfalseEvery secondPrint queries, for all resources or a JSON list
mysql_uifalseEvery secondEnables the mysql debug UI and its query log
mysql_log_size100 (10000 with mysql_debug)Every secondQueries kept per resource for the UI
mysql_transaction_isolation_level2At startIsolation level sent on each new connection
mysql_logger_serviceEmptyAt startLoads a module that receives oxmysql’s error logs
mysql_versioncheck1At start0 turns off the update check

mysql_versioncheck: when an update exists, oxmysql prints An update is available for oxmysql with your current version and a link to the release.

mysql_logger_service: a plain name loads logger/<name>.js from the oxmysql folder, where version 2.14.3 ships one module, fivemanage. A value that starts with @, as in @resource/path, loads a file from another resource. The code appends .js itself, while the 2.12.0 release notes write the example as @resource/path.js. Give the path without the extension.

mysql_transaction_isolation_level values

ValueStatement oxmysql sends
1SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
2 (default, also used for any other number)SET TRANSACTION ISOLATION LEVEL READ COMMITTED
3SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
4SET TRANSACTION ISOLATION LEVEL SERIALIZABLE

oxmysql sends this statement once on every new pool connection. The statement carries no SESSION or GLOBAL keyword, and MariaDB’s reference says that form sets the level “for only the next (not started) transaction” in the session, after which “it reverts to using the session value”. InnoDB’s default level is REPEATABLE READ. Read together, these sources mean the convar shapes the first transaction on each connection, and later transactions on that connection use the session level, which is REPEATABLE READ unless your database server is set up with another default. Neither the Qbox nor the ESX Legacy recipe sets this convar.

Troubleshooting

oxmysql stops with “mysql_connection_string structure was invalid”

The URI parser could not split the value, typically because of a # in the password. oxmysql reads the string before its connection attempt starts, so this error ends the attempts: there is no retry every 30 seconds as with a failed login. The error message repeats the entire connection string, password included, so remove the password before sharing the log. Change the password or rewrite the line in the key-value format, then restart the server.

“Access denied for user ‘root’@‘localhost’ (using password: NO)”

This is MariaDB error 1045. MariaDB’s reference says using password: NO means the client sent no password. With oxmysql, that usually means one of three things:

  • The convar is missing, misspelled or set in a file that runs after oxmysql starts, so oxmysql used its mysql://root@localhost fallback.
  • The URI has no :password part.
  • The key-value line uses Password= with a capital letter, or has a space before password=, and mysql2 ignores that key.

“Access denied for user ‘root’@‘localhost’” with no “using password” part

That is MariaDB error 1698, which MariaDB calls “the variant of error 1045 for authentication that doesn’t use a password”. It usually means the account logs in through unix_socket, the default for root on Linux, where root@localhost “has no usable password”. A password in the connection string makes no difference, because the plugin does not check one. Create a password account for FXServer, as the FiveM database setup guide shows, and put it in the line.

“Requested authentication using unknown plugin auth_gssapi_client”

oxmysql prints this when the database server asks for the auth_gssapi_client login method, which mysql2 does not have, and its common issues page lists it as AUTH_SWITCH_PLUGIN_ERROR (auth_gssapi_client). In the linked issue 213, oxmysql’s maintainer explains that the error “comes from the node-mysql2 which doesn’t support the specified authentication method” and advises to “just change your password or make a new account”. mysql2 3.24.5 supports caching_sha2_password, mysql_clear_password, mysql_native_password and sha256_password.

Login fails with “using password: YES” although the password is right

MariaDB’s reference says using password: YES only means a password was sent, not that it was correct. Check the password for the characters in the table above. A : in the URI format or a ; or = in the key-value format cuts the password short, and an escape such as %40 is sent as typed.

oxmysql connects, then queries fail with “No database selected”

That is MariaDB error 1046. When the value contains no database, oxmysql connects without one, so the connection message still appears and the first query on a table fails. Add the database name after the host in the URI, or database= in lower case in the key-value format.

“Ignoring invalid configuration option passed to Connection”

mysql2 received a key it does not know and skipped it; the message adds that a future mysql2 version will throw an error instead. Look for wrong capitalisation (Database, Host, Port), a misspelled option name, or an option from the older mysqljs library such as acquireTimeout, which is not in mysql2’s list of valid options.

Edits to mysql_connection_string change nothing

oxmysql reads the value once, when it starts, so restart the server. If the old value persists, search server.cfg and every file it loads with exec for a second set mysql_connection_string line.

“Empty mysql_connection_string detected”

This message comes from the old mysql-async resource: the 2019 forum thread that reports it shows mysql-async.js in the stack trace. oxmysql 2.14.3 does not stop on an empty value; it falls back to mysql://root@localhost. If you see this message, mysql-async is still installed and starting. The oxmysql documentation says you can delete mysql-async and ghmattimysql and let oxmysql provide their functions.

“Unable to establish a connection to the database (ECONNREFUSED)”

oxmysql’s common issues page calls this “an incredibly generic error” and lists three checks: the connection string is configured correctly, the database “exists and is running”, and the string has no reserved characters. Node.js describes ECONNREFUSED as a connection the target machine “actively refused”, usually because the service “is inactive” on that host. The oxmysql ECONNREFUSED guide goes through each cause.

“Too many connections”

MariaDB error 1040 means the database server reached max_connections. Each oxmysql pool can open up to its connectionLimit, so lower connectionLimit on the servers that share the database or raise MariaDB’s max_connections.

“multipleStatements is enabled. Used incorrectly, this option may cause SQL injection.”

Your string contains multipleStatements, even as multipleStatements=false, which mysql2 reads as on. oxmysql’s maintainers “strongly suggest” not enabling it, so remove it from the line.

“No such export” errors from oxmysql

The common issues page lists three reasons: oxmysql “has not yet started” when the export was called, it runs from unbuilt source code instead of a release build, or the export does not exist. Use the latest release and start it first; the No such export guide covers the general error.

The mysql command does nothing in game

The command quietly returns when mysql_ui is not true. Also check the permission: the documentation requires the command or command.mysql ACE, and oxmysql checks command.mysql again before it sends query data to the UI. The UI only lists queries that ran while mysql_ui was on.

Next Steps

Official documentation and repository references