Introduction
mysql-async was the reference 5 years ago. Today, oxmysql (by Overextended) is faster, better-maintained, supports native async/await, and has become the de facto standard. Starting a server in 2026? Use it.
Prerequisites
- A FiveM server at VeryCloud
- A MySQL/MariaDB DB (see fivem-sql tutorial on docs)
- Access to Files and Startup in Wisp
Step 1: Download oxmysql
oxmysql is on GitHub:
Download oxmysql.zip (official release, not source).
Step 2: Upload
In Wisp → Files → /resources/:
- Create
[mysql]folder (organization) if not already - Upload + extract
oxmysql.zip→ rename tooxmysql
Structure:
/resources/
└── [mysql]/
└── oxmysql/
├── fxmanifest.lua
├── lib/
├── dist/
└── README.md
Step 3: Configure connection
In /server.cfg, add connection string BEFORE ensure oxmysql:
set mysql_connection_string "mysql://user:password@host:3306/database?charset=utf8mb4"
ensure oxmysql
Concrete example:
set mysql_connection_string "mysql://fivem_user:[email protected]:3306/fivem_db?charset=utf8mb4"
💡 Escaping: if password contains
@,:,/,?, URL-encode it. Prefer alphanumeric.
Step 4: Restart and verify
Restart. FXServer console:
[oxmysql] Connection established
[oxmysql] Database 'fivem_db' is ready
If error:
Access denied: wrong credentials or source IP not in MySQL GRANTsConnection refused: port 3306 firewall or MySQL downUnknown database: DB doesn't exist
Step 5: Verify exports
oxmysql exposes global functions via FiveM exports. Test in chat F8:
exports.oxmysql:query('SELECT 1+1 AS result', {}, function(rs) print(json.encode(rs)) end)
[{"result":2}] in console = OK.
Step 6: Main methods
| Method | Usage |
|---|---|
oxmysql:query | Generic query, returns array of rows |
oxmysql:execute | INSERT/UPDATE/DELETE, returns affectedRows |
oxmysql:single | SELECT returning only one row (first result) |
oxmysql:scalar | SELECT returning only one value |
oxmysql:insert | INSERT, returns insertId |
oxmysql:transaction | Wrapper for atomic transactions |
Step 7: Lua examples
Simple SELECT:
exports.oxmysql:query(
'SELECT money FROM players WHERE identifier = ?',
{ 'steam:110000XXX' },
function(rs)
if rs and rs[1] then
print('Money:', rs[1].money)
end
end
)
INSERT:
local insertId = exports.oxmysql:insert_async(
'INSERT INTO logs (action, player, timestamp) VALUES (?, ?, NOW())',
{ 'login', 'steam:110000XXX' }
)
print('Inserted id:', insertId)
Async/await (CitizenFX):
local result = MySQL.query.await(
'SELECT * FROM players WHERE identifier = ?',
{ 'steam:110000XXX' }
)
Step 8: Migration from mysql-async
90% compatible APIs:
| mysql-async | oxmysql |
|---|---|
MySQL.Async.fetchAll | MySQL.query |
MySQL.Async.execute | MySQL.execute |
MySQL.Async.insert | MySQL.insert |
MySQL.Sync.fetchAll | MySQL.query.await |
Replace mysql-async with oxmysql in server.cfg, most code works as-is.
Step 9: Performance and pooling
oxmysql auto-manages a connection pool. Tune via:
set mysql_connection_string "..."
set mysql_debug "false"
set mysql_slow_query_warning 250 # warn if query > 250ms
⚠️
mysql_debug "true"in prod = log spam, killed perf. Debug only.
Step 10: Best practices
- Always use placeholders (
?): SQL injection protection - Index columns you filter on (
CREATE INDEX idx_identifier ON players(identifier)) - Local > remote DB: same node = 100x less latency
- Monitoring: enable
slow_query_warningto spot slow queries
Troubleshooting
Access denied for user — wrong user/pass, FiveM IP not in GRANT. Test from FiveM node: mysql -h HOST -u USER -p.
Can't connect to MySQL server — port 3306 blocked, DB not started.
Silent query failures — enable mysql_debug "true" temporarily.
Abnormally high latency — DB geographically far (prefer co-located), too many non-async queries blocking.
Useful commands
mysql -h HOST -u USER -p
SHOW PROCESSLIST;
SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 0.5;
Conclusion
oxmysql = 2026 standard for FiveM. Faster, more modern, native async/await. 10 min install, well-indexed DB, prepared queries: solid data layer for your whole server. Migration from mysql-async is trivial.
Going further: atomic transactions, prepared statement caching, slow query monitoring via Prometheus.


















