Skip to main content

Database Fundamentals

Databases are organized collections of information that allow applications and servers to persistently store, organize, and quickly retrieve data. In the context of Minecraft servers, they are responsible for storing all crucial information—from player permissions and statistics to server logs. Choosing the right database determines your server’s performance, stability, and scalability capabilities.


Types of Databases

DatabaseTypeKey FeaturesWhen to Choose?
MariaDBRelational (SQL)Traditional database with tables, secure transactions, support for complex SQL queries, and permanent storage on disk. In 90% of cases, it can be used instead of MySQL and is 13–36% faster.When you need structured data, assurance that nothing gets lost, and classic relationships between data. Ideal for Minecraft plugins and migration from MySQL.
Redis 6 & 7NoSQL, key-value, in-memoryExtremely fast, in-memory database (responses in fractions of a millisecond, millions of operations per second), excellent for caching, queues, and user session storage. Redis 7: improved memory management by 15–30%, new Redis Functions, ACLv2 with selectors, improved Sharded Pub/Sub.When you need instant access to temporary data, speed up other databases (10–100× faster reads), or real-time queue systems. Not suitable as the main database.
MongoDBNoSQL, document-orientedStores data as JSON-like documents, flexible structure without needing redesigns, scales across multiple servers, advanced data processing. Supports secure transactions between documents and automatic failover.When your data has irregular structures, you need rapid prototyping, large datasets from IoT devices, content management systems, or frequent changes in data structure.

When to Choose Which Database?

  • MariaDB for stability: Minecraft servers, online stores with payments, traditional websites, migrating from MySQL.
  • MongoDB for flexibility: Applications with quickly changing requirements, product catalogs, content management systems, applications for IoT devices.
  • Redis as a performance booster: Always to complement the main database—caching (10–100× faster), user sessions, leaderboards, task queues.

MariaDB

What Is MariaDB?

MariaDB is a free, open-source database that is a fork of MySQL. It is fully compatible with MySQL and is widely used in web applications and game servers, including Minecraft. MariaDB ensures persistent data storage.

Application of MariaDB

  • Structured data: Information requiring a stable structure and relationships between tables.
  • Financial transactions: Payments, server economy, stores where every penny counts.
  • Permission systems: Group hierarchies, roles, permissions with relations.
  • Logs and audits: Secure storage of activity history, data backup.
  • Inventory: Player items with exact properties and quantities.

MariaDB Configuration

The MariaDB database is fully configured and ready to use right after purchase.

Required Data for MariaDB Connection

Once MariaDB is running, you will need:

  • Server IP (IP-1 in the panel)
  • Port (usually found after : in IP-1)
  • Database name (which you create)
  • Username and password (which you create)

Common SQL Commands

The table below lists the most frequently used SQL commands, their descriptions, and example usage, useful for basic MariaDB database administration.

SQL CommandDescriptionExample Usage
CREATE DATABASE name;Creates a new databaseCREATE DATABASE luckperms;
USE name;Selects the database for further workUSE luckperms;
CREATE TABLE name (...);Creates a new table with specific schemaCREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50));
SHOW TABLES;Lists tables in the current database-
DESCRIBE name;Shows table structureDESCRIBE users;
INSERT INTO name (...) VALUES (...);Adds a new record to a tableINSERT INTO users (id, name) VALUES (1, 'Jan');
SELECT * FROM name;Retrieves all data from a tableSELECT * FROM users;
SELECT column FROM name WHERE condition;Fetches data matching criteriaSELECT name FROM users WHERE id = 1;
UPDATE name SET column=value WHERE condition;Updates table dataUPDATE users SET name='Anna' WHERE id=1;
DELETE FROM name WHERE condition;Removes records that match the conditionDELETE FROM users WHERE id=1;
DROP TABLE name;Deletes a table from the databaseDROP TABLE users;
ALTER TABLE name ADD column type;Adds a new column to the tableALTER TABLE users ADD age INT;
GRANT privileges ON db.* TO 'user'@'host';Grants privileges to a userGRANT ALL PRIVILEGES ON luckperms.* TO 'mc_luckperms'@'%';
FLUSH PRIVILEGES;Reloads privileges after changes-

Creating a Database and User

Creating a Database and User for a Plugin

To prepare MariaDB for integration with other services (e.g., LuckPerms plugin in Minecraft), run the following SQL commands:

CREATE DATABASE luckperms;
CREATE USER 'luckperms_user'@'%' IDENTIFIED BY 'YourPassword123!';
GRANT ALL PRIVILEGES ON luckperms.* TO 'luckperms_user'@'%';
FLUSH PRIVILEGES;

Example: Using MariaDB in Minecraft

Configuring LuckPerms with MariaDB

Open the config.yml in LuckPerms and locate the storage section:

plugins/luckperms/config.yml
storage-method: mariadb # or mysql

data:
address: 83.168.94.0:00000 # IP-1 from the panel with the port
database: luckperms # Created database name
username: luckperms_user # Created username
password: 'YourPassword123!' # User password

Additional Settings

If you repeatedly encounter errors such as:

No operations allowed after connection closed
Failed to validate connection (xxx cannot be called on a closed connection)

You need to adjust the maximum-lifetime setting in LuckPerms configuration and the wait_timeout setting in MariaDB.

It is crucial that the value of maximum-lifetime in LuckPerms’ configuration is less than the value of wait_timeout in MariaDB.

LuckPerms’ config.yml file:

  • Default maximum-lifetime: 1800000 (30 minutes in milliseconds)

MariaDB’s .my.cnf file:

  • Default wait_timeout: 600 (10 minutes in seconds)

Solution:

Reduce maximum-lifetime to a value 30 seconds less than wait_timeout on the MariaDB server.

plugins/luckperms/config.yml
  pool-settings:
maximum-lifetime: 1800000 → 570000 # from 30 minutes to 9 and a half minutes

Redis 6 & 7

What Is Redis?

Redis is a fast, in-memory database used as a server communication system. It does not store player data permanently—it only transfers messages between servers in real time (e.g., permissions synchronization, cross-server messaging, etc.).

Application of Redis

  • Cache and acceleration: Caching database query results (10–100× faster reads)
  • Real-time communication: Chats, notifications, inter-server synchronization (PubSub)
  • User sessions: Storing login and session data in RAM
  • Leaderboards: Live game leaderboards, contests, statistics
  • Task queues: Background task processing, notification systems

Redis Configuration

Setting a Password

  1. Find the Redis Password field in the Startup Parameters tab.
  2. Set a strong password (e.g., 0fiT0DCeripKV*s7!)
  3. Save changes and restart your Redis server.

Required Data for Redis Connection

Once Redis is running, you will need:

  • Server IP (IP-1 in the panel)
  • Port (usually found after : in IP-1)
  • Password (set in startup parameters)

Example: Using Redis in Minecraft

Configure LuckPerms Messaging

Apply the following configuration on at least two Minecraft servers with the LuckPerms plugin installed:

plugins/luckperms/config.yml
messaging-service: auto → redis

redis:
enabled: false → true
address: 83.168.94.0:00000 # IP-1 from the Console tab.
username: ''
password: '0fiT0DCeripKV*s7!' # Password set in Redis startup parameters.

Connection Testing

After restarting both servers, test as follows:

  1. On one server: /lp user [player_name] meta addprefix 100 "&aTEST"
  2. Check if the prefix appears immediately on the second server.
  3. The log on the second server should show: [luckperms]: [Messaging] Received user update ping

MongoDB

What Is MongoDB?

MongoDB is a free, open-source document-oriented NoSQL database that stores data in BSON (Binary JSON)—an extended version of JSON. Unlike relational databases (such as MariaDB/MySQL), MongoDB uses collections and documents instead of tables and rows.

Application of MongoDB

  • Player data storage with flexible structures (statistics, inventory, settings)
  • Authentication systems: Irregular data structures
  • Configurations: Various plugins, different data formats
  • Cache and sessions: Fast user data access
  • API data storage: Natural format for JSON/REST APIs

MongoDB Configuration

Setting the Admin Password

  1. Find the Mongo Admin Password field in the Startup Parameters tab.
  2. Set a strong password (e.g., 0fiT0DCeripKV*s7!).
  3. Save changes and start your MongoDB server.

Changing Password in MongoDB Console

After starting the server, you must access the Console tab and set the same admin password as in Startup Parameters:

use admin
db.changeUserPassword("admin", "0fiT0DCeripKV*s7!")

Required Data for MongoDB Connection

After configuring MongoDB, you will need:

  • Server IP (IP-1 in the panel)
  • Port (usually found after : in IP-1)
  • Username (admin or one you created)
  • Password (set in startup parameters)
  • Authentication Database (usually admin or custom)

Creating a Database and User in MongoDB

Basic Commands

  1. Switch to/create a database
use [database_name] # e.g., use luckperms
  1. Create a user with privileges
db.createUser({user:"username",pwd:"YourPassword123!",roles:[{role:"readWrite",db:"database_name"},{role:"dbAdmin",db:"database_name"}]}) # e.g., db.createUser({user:"luckperms_user",pwd:"YourPassword123!",roles:[{role:"readWrite",db:"luckperms"},{role:"dbAdmin",db:"luckperms"}]})
  1. Insert the first document to materialize the database
db.init.insertOne({created: new Date()})

Common MongoDB Commands

The table below shows the most important MongoDB commands, their descriptions, and examples:

MongoDB CommandDescriptionExample Usage
show dbsLists all databases-
use database_nameSwitches to the selected database (creates if missing)use luckperms
dbShows the current database-
show collectionsLists all collections in the current database-
db.collection.insertOne({...})Inserts one document into a collectiondb.users.insertOne({name:"Jan", age:25})
db.collection.insertMany([{...}])Inserts multiple documents into a collectiondb.users.insertMany([{name:"Anna"},{name:"Piotr"}])
db.collection.find()Fetches all documents from a collectiondb.users.find()
db.collection.find({...})Fetches documents matching the criteriadb.users.find({age: 25})
db.collection.findOne({...})Fetches the first document matching the criteriadb.users.findOne({name: "Jan"})
db.collection.updateOne({...}, {$set:{...}})Updates one documentdb.users.updateOne({name:"Jan"}, {$set:{age:26}})
db.collection.updateMany({...}, {$set:{...}})Updates multiple documentsdb.users.updateMany({age:25}, {$set:{status:"active"}})
db.collection.deleteOne({...})Deletes one documentdb.users.deleteOne({name:"Jan"})
db.collection.deleteMany({...})Deletes multiple documentsdb.users.deleteMany({age:{$lt:18}})
db.collection.drop()Drops the entire collectiondb.users.drop()
db.dropDatabase()Drops the entire database-

Example: Using MongoDB in Minecraft

Configuring LuckPerms with MongoDB

Open the config.yml in LuckPerms and configure the storage section:

plugins/luckperms/config.yml
storage-method: MongoDB

data:
address: 83.168.94.0:00000 # IP-1 from the panel with the port
database: luckperms # Created database name
username: luckperms_user # Created username
password: 'YourPassword123!' # User password

mongodb-collection-prefix: 'lp_' # Collection prefix
mongodb-connection-uri: '' # Leave empty
Method 2: Using Connection URI (Alternative)
plugins/luckperms/config.yml
storage-method: MongoDB

data:
mongodb-connection-uri: 'mongodb://luckperms_user:YourPassword123!@83.168.94.0:00000/luckperms'

Connection String for Other Applications

mongodb://username:YourPassword123!@83.168.94.0:00000/database_name