OPEN//77 connects to MySQL or MariaDB through a built-in database bridge that is off by default. To enable it: install a database server, create a database and a dedicated user, set database.enabled to true in server.jsonc, supply a connection string through the OP77_DATABASE_CONNECTION environment variable, and restart the server. Then confirm the connection from a server-side Lua resource.
This guide follows the official documentation step by step and covers the errors that most often block the connection. It doesn’t try to be a general MySQL tutorial.
Does OPEN//77 Require a Database?
No. The bridge is disabled by default, and the server distribution doesn’t install a database service or create SQL credentials for you. A server can run without any database.
You need one when your server’s resources store persistent data in SQL. Enabling SQL also activates persistence paths in other loaded resources that asked for it, such as appearance storage, so review your resources before switching it on.
Two lighter options exist for small needs: server KVP (a key/value store) and SQLite, where a resource opens and manages its own database file with no service and no server.jsonc setting.
SQL runs on the server side, never on a player’s PC. Players connect to the game server and never to your database.
MySQL vs MariaDB: Which Should You Use?
The official documentation supports both through the same bridge. MySQL and Open77.database expose the same API in Lua, and no oxmysql resource is required.
- Supported: MySQL and MariaDB.
- Not supported: PostgreSQL and Microsoft SQL Server.
- Documented examples: MariaDB on Debian/Ubuntu. The documentation notes the equivalent MySQL client command simply starts with
mysql. - Versions: the documentation doesn’t list minimum or supported version numbers. Test your chosen version on a staging server before relying on it.
You can also use an existing compatible service instead of installing a new one.
Prerequisites Before Database Setup
- A working OPEN//77 dedicated server. If you haven’t built one yet, read how to host an OPEN//77 server first.
- Administrator access to the machine that will run the database (
sudoon Linux or an administrator account on Windows). - The
server.jsoncfile you actually launch. Edits to any other copy won’t take effect. - A decision on placement. The simplest arrangement is SQL and OPEN//77 on the same host, with SQL listening on loopback.
How to Install or Prepare a Database
The official documentation gives these commands for a new Debian/Ubuntu host:
sudo apt update
sudo apt install mariadb-server mariadb-client
sudo systemctl enable --now mariadb
sudo systemctl status mariadb
sudo mariadb-secure-installation
On Windows, use the MariaDB installer, enable the database as a Windows service, and keep its TCP port at 3306 unless another service already uses it. For other distributions, follow the official MariaDB installation guide.
Don’t open port 3306 to the public internet for a local database.
If you’d rather not run and secure a database service yourself, OPEN//77 server hosting is one alternative. The settings below stay the same either way.
How to Create a Database and Database User
Open an administrative SQL session. On a typical Debian/Ubuntu MariaDB installation, sudo mariadb uses the local administrative socket.
- Run this once, replacing the password placeholder with a unique secret:
CREATE DATABASE open77 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'open77'@'127.0.0.1' IDENTIFIED BY 'REPLACE_WITH_A_UNIQUE_PASSWORD';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX
ON open77.* TO 'open77'@'127.0.0.1';
These grants allow normal reads and writes and common table migrations in this one database only. Add privileges such as DROP only when a reviewed resource migration actually requires them.
- Test the same TCP connection OPEN//77 will use, from the game server’s machine:
mariadb --protocol=TCP --host=127.0.0.1 --port=3306 --user=open77 --password open77
The client prompts for the password, so it never appears in the command. In that session, run:
SELECT DATABASE(), CURRENT_USER(), 1 AS connection_ok;
This proves authentication and database selection. It doesn’t prove every resource has the privileges it needs.
Account host matters. SQL accounts include a host part. An account at 127.0.0.1 is not a catch-all, and MariaDB treats TCP loopback differently from localhost socket authentication. Keep the account host and connection method consistent.
How to Configure OPEN//77 Database Connectivity
Step 1: Add the database block to server.jsonc
Merge this object into your existing server.jsonc. Don’t replace the rest of the file:
{
"database": {
"enabled": true,
"connectionString": "",
"connectionStringEnvironmentVariable": "OP77_DATABASE_CONNECTION",
"maxRows": 10000
}
}
| Setting | Meaning |
|---|---|
database.enabled |
false by default. Must be true to create the bridge. |
database.connectionString |
An explicit non-blank value takes precedence over the environment. Leave it empty when using an environment secret. |
database.connectionStringEnvironmentVariable |
The name of the variable to read (default OP77_DATABASE_CONNECTION). This is a variable name, not the password. |
database.maxRows |
Maximum rows one query returns. Default 10000, accepted range 1 to 1000000. Extra rows are truncated with a warning, not paginated automatically. |
Step 2: Provide the connection string
OPEN//77 uses a MySqlConnector connection string. It is a semicolon-separated string, not a mysql:// URL and not FiveM’s set mysql_connection_string directive.
Linux, for a manual launch from the same shell:
export OP77_DATABASE_CONNECTION='Server=127.0.0.1;Port=3306;Database=open77;User ID=open77;Password=REPLACE_WITH_A_UNIQUE_PASSWORD;'
Windows PowerShell, for a manual launch from the same session:
$env:OP77_DATABASE_CONNECTION = 'Server=127.0.0.1;Port=3306;Database=open77;User ID=open77;Password=REPLACE_WITH_A_UNIQUE_PASSWORD;'
Launch your normal OPEN//77 server command from that same shell or session.
These examples show syntax with a placeholder. Typing a real password directly can leave it in shell history. For production, use your host’s protected secret mechanism. For systemd, containers or hosting panels, set the variable in that service, container or panel. Exporting it in an unrelated SSH shell doesn’t change a running service’s environment. OPEN//77 does not load an arbitrary .env file automatically.
Step 3: Restart the server
Restart the dedicated server after changing these settings. Reloading only a Lua resource does not recreate the server-wide database bridge. An enabled bridge with no effective connection string fails configuration validation at startup.
If the database is on another machine
Use the database host’s reachable name in Server, and create a SQL account restricted to the game server’s connecting address. Restrict the database firewall to that source too. In a container, 127.0.0.1 means that container, so another container normally needs its service name and a shared network.
For remote production connections, the documentation recommends TLS with certificate and hostname validation:
Server=db.example.net;Port=3306;Database=open77;User ID=open77;Password=REPLACE_WITH_A_UNIQUE_PASSWORD;SslMode=VerifyFull;
If your provider uses a private CA, add its supplied SslCa file path. SslMode=Required encrypts the connection but doesn’t validate the certificate’s identity, so it is not equivalent to VerifyFull.
How to Test the Database Connection
Work through these in order. Each proves something different.
- The command-line test from the account creation step proves the credentials and TCP route work.
- The startup log shows two messages.
Database bridge enabled (maxRows=10000).only means the bridge is configured.Database bridge reachable; MySQL.ready handlers released.appears after a realSELECT 1probe succeeds. - A Lua probe proves the full chain, including permission and parameter binding, without creating or changing any tables.
Only server scripts with the database.access permission can use SQL. Create a resource named sql_probe in your resources directory with these two files:
-- open77.lua
resource "sql_probe"
version "1.0.0"
server_script "server.lua"
permissions { "database.access" }
-- server.lua
local queued, reason = MySQL.ready(function()
local ok, result = pcall(function()
return MySQL.scalar.await("SELECT ?", { 77 })
end)
if not ok then
print("[sql_probe] query failed: " .. tostring(result))
return
end
print("[sql_probe] connected; parameterized SELECT returned " .. tostring(result))
end)
if not queued then
print("[sql_probe] readiness refused: " .. tostring(reason))
else
local ready, state = MySQL.isReady()
print("[sql_probe] state: " .. (ready and "ready" or tostring(state)))
end
In the server console or the Warden console, run:
refresh
ensure sql_probe
You should see:
Database bridge enabled (maxRows=10000).
Database bridge reachable; MySQL.ready handlers released.
[sql_probe] connected; parameterized SELECT returned 77
MySQL.ready is a startup gate, not a live health check. Before the first successful connection, the server retries with a backoff of up to 30 seconds. After that first success, readiness doesn’t revert during a later outage, so resources must handle failures of individual queries.
Running --check-config validates your configuration but doesn’t test database credentials or reachability. The steps above do.
Common MySQL and MariaDB Connection Errors
| Symptom | What to check |
|---|---|
| Startup rejects the database configuration | The effective connection string is empty, the variable name is blank, or maxRows is outside 1 to 1000000. |
Database bridge disabled. / database_unavailable |
Check database.enabled in the config you actually launched, and restart after changes. |
database_connecting |
The first probe is still pending. Wait for the “reachable” message. |
database_unreachable |
Read the first probe warning. Test the same host, port and account from the server machine, and check the SQL service. |
| Access denied | Check the password, account host, authentication method and grants. A local administrator’s socket login doesn’t prove the application’s TCP login works. |
| Unknown database | Create the database and check its exact spelling. The bridge doesn’t create it. |
| Connection refused or timeout | Check the SQL listener, port, container network, firewall and host name. Don’t open SQL to every IP as a workaround. |
| TLS or certificate failure | Use the certificate’s hostname, the correct CA and a valid server certificate, and check the host clock. Don’t disable verification to hide the problem. |
permission_denied:database.access |
Declare the permission in the calling resource and reload that resource. |
MySQL is missing in Lua |
The code is running on the client. Keep database code in a server_script. |
| Missing table or migration denied | Run the resource’s reviewed migration and grant only the privileges it requires on this database. |
| Queries fail after the ready callback ran | Handle each query failure explicitly. Startup readiness is not a live availability guarantee. |
| Fewer rows than expected | Check for the maxRows truncation warning, and use explicit ordering and bounded queries. |
Before sharing logs when asking for help, remove credentials, connection strings and sensitive query data.
Database Security and Maintenance Best Practices
- Use a dedicated account. Never give the game server the SQL administrator account or global
*.*privileges. - Grant the minimum. The documented grants cover one database only. Add extra privileges only when a reviewed migration needs them.
- Keep SQL off the public internet. Bind to loopback for a local database, and restrict the firewall to the game server’s address for a remote one.
- Keep credentials out of
server.jsonc. Use the environment variable, and restrict access to any environment file that holds credentials. - Remember the database is shared. Every resource with
database.accessuses the same configured database and SQL account. The permission doesn’t give each resource a private schema, so review what you install. - Bind values, never concatenate. Use
?or named@parametersfor query values. Key player data by a persistent authenticated identity, not a temporary session ID. - Back up the database itself. A copy of
resources/is not a backup of SQL data. Test restores into a separate database, and back up before changing a live server’s persistence behavior. - Bound your queries.
maxRowstruncates silently apart from a warning, so use ordering and pagination instead of relying on it.
Frequently Asked Questions
Does OPEN//77 require a database?
No. The database bridge is disabled by default and the server runs without it. You only need MySQL or MariaDB if your resources store persistent data in SQL. Lighter options are server KVP and SQLite.
Does OPEN//77 support MySQL and MariaDB?
Yes, both are supported through the same built-in bridge, with no oxmysql resource required. PostgreSQL and Microsoft SQL Server are not supported. The official documentation doesn’t list specific supported version numbers.
What connection string format does OPEN//77 use?
A MySqlConnector connection string, for example Server=127.0.0.1;Port=3306;Database=open77;User ID=open77;Password=...;. It is not a mysql:// URL and not a FiveM mysql_connection_string setting. Supply it through the OP77_DATABASE_CONNECTION environment variable.
How do I check that OPEN//77 is connected to the database?
Look for Database bridge reachable; MySQL.ready handlers released. in the startup log, which appears after a real probe succeeds. For a full check, run a small server-side Lua probe that calls MySQL.scalar.await("SELECT ?", { 77 }) from a resource with the database.access permission.
Why do I get “Access denied” when OPEN//77 connects to MariaDB?
Check the password, the account’s host part, the authentication method and the grants. An account at 127.0.0.1 differs from localhost socket authentication, so test with --protocol=TCP from the game server machine. A successful administrator login doesn’t prove the application account works.

