How To Set Up a Database for Your RedM Server (MariaDB)
Learn how to install and configure MariaDB for your RedM server on Linux, including user creation and remote access.
Most RedM frameworks (such as VORP, RSG, and RedEM) require a MySQL-compatible database. This guide covers setting up MariaDB on a Linux server.
📝 Note: If you are using XGamingServer's managed hosting, a database is provided for you via the panel — you do not need to install MariaDB manually. This guide is for self-hosted or VPS deployments.
Step 1 — Update Your System
Before installing any package, update your system's package list:
sudo apt-get update && sudo apt-get upgrade -y⚠️ Note: Always run commands as a user with sudo privileges. It is best practice to keep root SSH access disabled. Read more about Linux server security.
Step 2 — Install MariaDB
sudo apt-get install mariadb-server -yFollow any on-screen prompts during installation.
Step 3 — Run the Secure Installation
Once installed, run the security script to harden your database:
sudo mysql_secure_installationThe script will walk you through:
- Setting a root password
- Removing anonymous users
- Restricting root login to localhost
- Removing the test database
- Reloading privilege tables
💡 Tip: Answer Y (yes) to all questions for a secure setup.
Step 4 — Log In to MariaDB
mysql -u root -pEnter the root password you set above. If you forgot it, a sudo user can bypass authentication with:
sudo mysql -u rootStep 5 — Create a Database User
Inside the MariaDB console, create a dedicated user for your RedM server. Replace youruser and yourpassword with your own values.
CREATE USER 'youruser'@'%' IDENTIFIED BY 'yourpassword';
SELECT User FROM mysql.user;
GRANT ALL PRIVILEGES ON *.* TO 'youruser'@'%' IDENTIFIED BY 'yourpassword';
FLUSH PRIVILEGES;📝 Note: Using
%as the host allows connections from any IP address, which is required if you are connecting remotely (e.g. from HeidiSQL on your PC). For a local-only setup, uselocalhostinstead.
Step 6 — Create a Database
Create a dedicated database for your framework:
CREATE DATABASE redm;
EXIT;Step 7 — Allow Remote Connections
By default, MariaDB only accepts local connections. To allow remote access, edit the configuration file:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnfFind the bind-address line and change it from 127.0.0.1 to 0.0.0.0:
bind-address = 0.0.0.0Save and exit with CTRL+X, then Y, then Enter.
Step 8 — Restart MariaDB
Apply the configuration change:
sudo systemctl restart mariadbVerify it is running:
sudo systemctl status mariadbStep 9 — Open the MySQL Port
MariaDB uses port 3306. Open it in your firewall with iptables:
sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT⚠️ Warning: Opening port 3306 exposes your database to the internet. Make sure you are using a strong password and not using the root account for your server connection.
You can verify the port is reachable using portchecker.co.
Connecting Your Framework
Your database connection string will look like this (used in oxmysql or framework config):
mysql://youruser:yourpassword@your-server-ip/redmOr in connection string format:
server=your-server-ip;database=redm;userid=youruser;password=yourpassword;💡 Tip: Need help setting up the database? Join our Discord for support.
Next Steps
How is this guide?
