The Lab
Install guide

Install oxmysql on RedM

oxmysql is the MySQL driver most RedM frameworks and scripts use. It must be installed from a release build, configured with one convar, and started before anything that touches the database.

Estimated time: 10 min

Before you start

  • A MySQL or MariaDB server reachable from the game server
  • A database and a user with rights on it

Install steps

  1. Step 1: Download the release build

    Take the archive from the oxmysql GitHub releases page, not the green "Code" download: the repository source must be built first, the release is ready to run. Extract it so you get resources/oxmysql/fxmanifest.lua.

  2. Step 2: Create the database

    If your framework does not create it for you, create an empty database with a utf8mb4 charset and a user for the server.

    CREATE DATABASE redm CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    CREATE USER 'redm'@'localhost' IDENTIFIED BY 'change-me';
    GRANT ALL PRIVILEGES ON redm.* TO 'redm'@'localhost';
  3. Step 3: Set the connection string

    Add the convar to server.cfg with set (not setr), before ensure oxmysql. The URI form is the most common. Characters such as ; , / ? : @ & = + $ # in the password can break the string: avoid them, or use the key-value form instead.

    set mysql_connection_string "mysql://redm:change-me@localhost:3306/redm"
  4. Step 4: Ensure it first

    oxmysql goes before the framework and before every script that imports @oxmysql/lib/MySQL.lua.

    ensure oxmysql
    # framework and scripts below
  5. Step 5: Check the connection

    On start, oxmysql logs whether it connected. Fix any error there before installing scripts that use the database.

Troubleshooting

ECONNREFUSED

The database server is not running, or the host and port are wrong. On a separate machine, use its address instead of localhost.

Access denied for user

Wrong user or password, or the user was created for another host ('redm'@'localhost' cannot connect from another machine).

Unknown database

The database name at the end of the URI does not exist. Create it, or fix the name.

Scripts fail with MySQL errors at boot

They start before oxmysql. Move ensure oxmysql to the top.

FAQ

MySQL or MariaDB?

Both can be used. The oxmysql docs recommend MariaDB for compatibility, so pick it when your host gives you the choice.

Is there another connection string format?

oxmysql also accepts a key-value form such as user=redm;password=change-me;host=localhost;port=3306;database=redm.

Do The Lab scripts need oxmysql?

The Lab Id and The Lab Telegram do. The Lab Hud and The Lab Devtools do not use a database.