Move a resource from mysql-async to oxmysql by changing its driver setup and reviewing each query’s parameters, return value and error handling. A driver migration does not require rewriting your database schema; measure any speed gain yourself.
SQL import or connection errors with a resource from RPScripts? See SQL files and database errors.
What oxmysql is
oxmysql is a resource for FXServer that connects your FiveM server to a MySQL or MariaDB database through the node-mysql2 library. Its documentation describes it as a replacement of mysql-async and ghmattimysql with an expanded API and improved compatibility for MySQL 8, and it supports the mysql-async and ghmattimysql syntax. Its manifest declares provide 'mysql-async' and provide 'ghmattimysql'. In FiveM, provide marks a resource as a replacement, so a resource that requires either name starts oxmysql instead.
Where oxmysql lives today
As of 24 November 2026, oxmysql is developed in the overextended/oxmysql repository on GitHub. The repository is not archived, the latest release is v2.14.3 (published 6 October 2026) and the main branch was last updated on 22 November 2026. The documentation is at overextended.dev/oxmysql. For comparison, the last update to the mysql-async repository (brouznouf/fivem-mysql-async) was on 6 March 2023.
The manifest of release v2.14.3 requires server build 12913 or newer ('/server:12913') and Node.js 22 (node_version '22'), so check your server artifact before you update. oxmysql is licensed under LGPL-3.0-or-later.
Prepare a recoverable test
Back up the database and matching resources, then work on an isolated copy. A database client helps with the backup and with inspecting tables; HeidiSQL vs Navicat compares two common ones. Inventory every resource using mysql-async and check whether your framework already requires oxmysql. Record the installed driver release. Review the oxmysql source and installation instructions for that release before switching drivers.
Install oxmysql and set the connection string
The oxmysql documentation recommends MariaDB. Most FiveM resources were designed for MySQL 5.7 and can hit problems on MySQL 8, which has more reserved keywords (such as stored and group) and does not support default values for longtext and JSON fields. The documentation also says not to set up XAMPP just to run the database: install MariaDB directly.
- Install MariaDB.
- Download
oxmysql.zip from the latest release and place the oxmysql folder in your resources folder. - In
server.cfg, set mysql_connection_string before any resource starts, then start oxmysql at the top of your resource list.
set mysql_connection_string "mysql://user:password@localhost:3306/database"
ensure oxmysql
ensure your_framework
Replace user, password and database with your own values. The documentation shows two formats, the URI above and the semicolon format user=user;password=password;host=localhost;port=3306;database=database, and says to only ever use set for this setting.
Certain special characters are reserved or unsupported depending on the format. Avoid ; , / ? : @ & = + $ # in the connection string, and try the other format if the connection fails.
The connection-string parser in the oxmysql source also rewrites older key names such as server, userid and db to host, user and database, so an existing mysql-async-style string may keep working. Test it rather than assuming it.
Where these lines belong in the rest of the file is covered in the FiveM server.cfg guide.
Load the connection before the driver
In the active server.cfg, keep the existing private mysql_connection_string setting above ensure oxmysql. Start dependent resources afterwards. Do not publish connection credentials in support logs. Remove the old driver startup only after every dependent resource has been accounted for. oxmysql’s documentation says you can delete mysql-async and ghmattimysql and let oxmysql provide their functionality. If a dependent resource does not start after the switch, the checks in FiveM resource won’t start apply.
In each Lua resource that uses the MySQL global, load the library before its server scripts:
server_scripts {
'@oxmysql/lib/MySQL.lua',
'server/*.lua'
}
dependency 'oxmysql'
Choose the result you need
Use MySQL.query.await for a set of rows, MySQL.single.await for one row, MySQL.scalar.await for one value, MySQL.insert.await for an insert ID and MySQL.update.await for affected rows. Check the documented return for your query; an empty result is different from an error.
Code that still calls the mysql-async style functions is mapped by oxmysql’s lib/MySQL.lua (read in the repository on 24 November 2026): MySQL.Async calls become the callback form and MySQL.Sync calls the .await form of these functions.
| mysql-async call | oxmysql function | Returns, per the oxmysql documentation |
|---|
MySQL.Async.fetchAll, MySQL.Sync.fetchAll | MySQL.query, MySQL.query.await | All matching rows of a SELECT; otherwise data such as insertId and affectedRows |
fetchSingle | MySQL.single | All selected columns of a single row |
fetchScalar | MySQL.scalar | The first column of a single row |
insert | MySQL.insert | The insert ID of the new row |
execute | MySQL.update | The number of affected rows |
transaction | MySQL.transaction | A boolean, the result of the transaction |
prepare | MySQL.prepare | A SELECT returns a column, a row or an array of rows depending on what was selected; only ? and ?? placeholders are allowed, named placeholders throw an error |
A manifest change alone can therefore be enough for a resource that only uses these calls, but test each one as described below.
This server-side example tests a parameterized round trip without touching a gameplay table. Run it from a resource after oxmysql has started:
CreateThread(function()
local ok, value = pcall(function()
return MySQL.scalar.await('SELECT ?', { 'connection-ok' })
end)
if ok and value == 'connection-ok' then
print('Database parameter check passed.')
else
print('Database parameter check failed; inspect the server log privately.')
end
end)
Review every converted call
Replace interpolated user values with positional ? placeholders and an ordered parameter table. Table and column identifiers require a fixed allowlist; value placeholders cannot select arbitrary SQL identifiers. The oxmysql placeholder documentation marks named placeholders (@name) as deprecated.
Await changes control flow: use the result after the await returns, handle missing rows and exceptions, and check whether the player is still connected before acting. A successful SQL write does not automatically update a framework’s in-memory player state.
Keep transactions on one connection
Use the driver’s documented transaction API for grouped SQL work. Separate START TRANSACTION, query and COMMIT calls through a connection pool do not guarantee that all statements use the same connection.
A transaction succeeding means its SQL statements did not fail. An UPDATE affecting zero rows can still be valid SQL. Payment and inventory logic must enforce business conditions explicitly; do not copy a generic balance-transfer snippet into a live economy.
Verify correctness before speed
- Search for remaining mysql-async imports, exports and callback patterns. Verify each caller receives the shape it expects.
- Test login, character creation, saving, reconnect, inventory, garages and relevant job actions using known records. Test unavailable database and rejected input.
- Compare expected row changes and persisted balances. Keep schema/index changes separate from this driver migration.
- For performance, measure the same gameplay action and workload before and after. Investigate slow queries with their execution plans; add indexes only after inspecting the actual schema and query. While testing,
set mysql_debug true prints every query to the server console and mysql_slow_query_warning controls the slow-query warnings; the documentation notes that query time may not be entirely accurate and that a slow query does not always point to a database problem.
Release and rollback
Schedule a maintenance window, deploy the matched driver/resource set and run the same checks. Keep the old set private for rollback. Restore a database backup only if needed for changed data or schema, and account for all writes since that backup. Converting text back to a smaller character set is not a safe generic rollback.
Reference documentation
Source: overextended/oxmysql
Documentation: overextended.dev/oxmysql