Database Basics
Databases are organized collections of information that enable applications and servers to persistently store, organize, and quickly access data. In the context of Minecraft servers, they are responsible for storing all key information - from player permissions and statistics to server logs. Choosing the right database determines the performance, stability, and scalability of your server.
Database Types
| Database | Type | Key Features | When to Choose? |
|---|---|---|---|
| MariaDB | Relational (SQL) | A traditional database with tables, secure transactions, support for complex SQL queries, and persistent on-disk data storage. In 90% of cases, it can be used instead of MySQL, and it runs 13-36% faster. | When you need structured data, assurance that nothing will be lost, and classic relationships between data. Ideal for Minecraft plugins and migrating from MySQL. |
| Redis 6 & 7 | NoSQL, key-value, in-memory | An extremely fast database running in the computer's memory (responses in fractions of a millisecond, millions of operations per second), great for caching, queues, and saving user sessions. Redis 7: 15-30% better memory management, new Redis Functions, ACLv2 with selectors, improved Sharded Pub/Sub. | When you need lightning-fast access to temporary data, accelerating other databases (10-100 times faster reads), or real-time queue systems. Not suitable as a primary database. |
| MongoDB | NoSQL, document | Stores data as JSON-like documents, flexible structure without the need for rebuilding, scalability across multiple servers, advanced data processing. Supports secure transactions between documents and automatic failover to backup servers. | When data has an irregular structure, you need rapid prototyping, handling large datasets from IoT devices, content management systems, or when the application requires frequent changes to the 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 rapidly changing requirements, product catalogs, content management systems, IoT device applications.
- Redis as an accelerator: Always as a supplement to the primary database - acceleration (10-100 times 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 widely used in web applications and game servers, including Minecraft. MariaDB provides persistent data storage.
What is MariaDB used for in applications?
- Structured data – information requiring a permanent structure and relationships between tables.
- Financial transactions – payments, server economy, shops where every single penny counts.
- Permission systems – group hierarchies, roles, permissions with relationships.
- Logs and audits – secure storage of action history, data backup.
- Inventory and items – player items with precise properties and quantities.
MariaDB Configuration
The MariaDB database is fully configured and ready to use immediately upon purchase.
Any change to a user password or database permissions requires a full restart of the database server for the new credentials to be properly applied by the system.
Required Connection Data for MariaDB
After launching MariaDB, you will need:
- Server IP (
IP-1in the panel) - Port (by default found after the
:colon inIP-1) - Database Name (the one you create)
- Username and Password (the ones you create)
Basic SQL Commands
The table below presents a set of the most frequently used SQL commands along with a description and an example of use, which will help with basic operation of the MariaDB database.
| SQL Command | Description | Example Use |
|---|---|---|
CREATE DATABASE name; | Creates a new database | CREATE DATABASE luckperms; |
USE name; | Selects a database for further work | USE luckperms; |
CREATE TABLE name (...); | Creates a new table with a specified structure | CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50)); |
SHOW TABLES; | Displays a list of tables in the current database | - |
DESCRIBE name; | Displays the table structure | DESCRIBE users; |
INSERT INTO name (...) VALUES (...); | Adds a new record to the table | INSERT INTO users (id, name) VALUES (1, 'John'); |
SELECT * FROM name; | Retrieves all data from the table | SELECT * FROM users; |
SELECT column FROM name WHERE condition; | Retrieves data matching a condition | SELECT name FROM users WHERE id = 1; |
UPDATE name SET column=value WHERE condition; | Updates data in the table | UPDATE users SET name='Anna' WHERE id=1; |
DELETE FROM name WHERE condition; | Deletes records matching a condition | DELETE FROM users WHERE id=1; |
DROP TABLE name; | Deletes a table from the database | DROP TABLE users; |
ALTER TABLE name ADD column type; | Adds a new column to the table | ALTER TABLE users ADD age INT; |
GRANT permissions ON db.* TO 'user'@'host'; | Grants privileges to a user | GRANT ALL PRIVILEGES ON luckperms.* TO 'mc_luckperms'@'%'; |
FLUSH PRIVILEGES; | Reloads privileges after changes | - |
Creating a Database and a User
Creating a database and a user for a plugin
To prepare the MariaDB database to work with other services (e.g., the LuckPerms plugin in Minecraft), execute 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 of Using MariaDB in Minecraft
Configuring LuckPerms with MariaDB
Open the LuckPerms config.yml file and locate the storage section:
storage-method: mariadb # or mysql
data:
address: 83.168.94.0:3306 # IP-1 from the panel along with the port
database: luckperms # Name of the created database
username: luckperms_user # Created user
password: 'YourPassword123!' # User password
Additional Settings
If you keep receiving an error similar to:
No operations allowed after connection closed
Failed to validate connection (xxx cannot be called on a closed connection)
You must adjust the maximum-lifetime setting in the LuckPerms configuration and wait_timeout in MariaDB.
It is crucial that the maximum-lifetime value in the LuckPerms configuration is less than the wait_timeout value in the MariaDB configuration.
config.yml file in the LuckPerms plugin:
- Default maximum-lifetime:
1800000(30 minutes in milliseconds)
.my.cnf file on the MariaDB server:
- Default wait_timeout:
600(10 minutes)
Problem Solution:
Reduce maximum-lifetime to a value 30 seconds shorter than the wait_timeout on the MariaDB server.
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 (stored in RAM) used on servers as a communication system between servers. It does not permanently store player data - it only relays messages between servers in real time (e.g., permission synchronization, cross-server messages, etc.).
What is Redis used for in applications?
- Cache and acceleration – caching database query results (10-100x faster reads).
- Real-time communication – chats, notifications, cross-server synchronization (PubSub).
- User sessions – storing login data and sessions in RAM.
- Leaderboards and rankings – score tables in games, contests, live statistics.
- Task queues – background task processing, notification systems.
Redis Configuration
Setting a Password
- In the Startup Parameters tab, locate the
Redis Passwordfield. - Set a strong password (e.g.,
YourPassword123!). - Save changes and restart the Redis server.
After changing the password in the Redis Password field, a full restart of the Redis service is required for the new authentication key to be loaded.
Required Connection Data for Redis
After launching Redis, you will need:
- Server IP (
IP-1in the panel) - Port (by default found after the
:colon inIP-1) - Password (the one you set in the parameters)
Example of Using Redis in Minecraft
Open the LuckPerms config.yml file and locate the messaging section
Apply the following configuration on at least two Minecraft servers with the LuckPerms plugin installed:
messaging-service: auto → redis
redis:
enabled: false → true
address: 83.168.94.0:6379 # IP-1 from the Console tab.
username: ''
password: '0fiT0DCeripKV*s7!' # Password set in Redis Startup Parameters.
Testing the Connection
After restarting the servers, perform a test:
- On one server:
/lp user [player_name] meta addprefix 100 "&aTEST" - Check on the second server if the prefix appears instantly.
- In the logs of the second server, you should see:
[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) format - an extended version of JSON. Unlike traditional relational databases (like MariaDB/MySQL), MongoDB does not use tables and rows, but rather collections and documents.
What is MongoDB used for in applications?
- Storing player data with a flexible structure (statistics, inventory, settings).
- Authentication systems – irregular data structures.
- Configurations – different plugins, different data formats.
- Cache and sessions – fast access to user data.
- API data storage – native fit for JSON/REST APIs.
MongoDB Configuration
Setting the Administrator Password
- In the
Startup Parameterstab, find theMongo Admin Passwordfield. - Set a strong password (e.g.,
YourPassword123!). - Save changes and start the MongoDB server.
Changing the Password in the MongoDB Console
After launching the server, you must open the Console tab and set the same password for the admin user as you did in Startup Parameters:
use admin
db.changeUserPassword("admin", "YourPassword123!")
Setting a new administrator password in the Startup Parameters and Console will become fully active for external connections only after conducting a full restart of the MongoDB database.
Required Connection Data for MongoDB
After configuring MongoDB, you will need:
- Server IP (
IP-1in the panel) - Port (by default found after the
:colon inIP-1) - Username (
adminor one created by you) - Password (the one you set in the parameters)
- Authentication Database (usually
adminor the created one)
Creating a Database and a User in MongoDB
Basic Commands
- Switch to/create a database:
use [database_name] # e.g., use luckperms
- Create a user with permissions:
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"}]})
- Insert the first document so the database is actually created:
db.init.insertOne({created: new Date()})
Basic Most Frequently Used MongoDB Commands
The table below presents a set of the most important MongoDB commands along with a description and an example of use:
| MongoDB Command | Description | Example Use |
|---|---|---|
show dbs | Displays a list of all databases | - |
use db_name | Switches to the specified database (creates it if it doesn't exist) | use luckperms |
db | Displays the current database | - |
show collections | Displays collections in the current database | - |
db.collection.insertOne({...}) | Inserts one document into the collection | db.users.insertOne({name:"Jan", age:25}) |
db.collection.insertMany([{...}]) | Inserts multiple documents into the collection | db.users.insertMany([{name:"Anna"},{name:"Piotr"}]) |
db.collection.find() | Retrieves all documents from the collection | db.users.find() |
db.collection.find({...}) | Retrieves documents matching a condition | db.users.find({age: 25}) |
db.collection.findOne({...}) | Retrieves the first document matching a condition | db.users.findOne({name: "Jan"}) |
db.collection.updateOne({...}, {$set:{...}}) | Updates a single document | db.users.updateOne({name:"Jan"}, {$set:{age:26}}) |
db.collection.updateMany({...}, {$set:{...}}) | Updates multiple documents | db.users.updateMany({age:25}, {$set:{status:"active"}}) |
db.collection.deleteOne({...}) | Deletes a single document | db.users.deleteOne({name:"Jan"}) |
db.collection.deleteMany({...}) | Deletes multiple documents | db.users.deleteMany({age:{$lt:18}}) |
db.collection.drop() | Deletes the entire collection | db.users.drop() |
db.dropDatabase() | Deletes the entire database | - |
Example of Using MongoDB in Minecraft
Configuring LuckPerms with MongoDB
Method 1: Basic Configuration (Recommended)
Open the LuckPerms config.yml file and configure the storage section:
storage-method: MongoDB
data:
address: 83.168.94.0:27017 # IP-1 from the panel along with the port
database: luckperms # Name of the created database
username: luckperms_user # Created user
password: 'YourPassword123!' # User password
mongodb-collection-prefix: 'lp_' # Prefix for collections
mongodb-connection-uri: '' # Leave empty
Method 2: Using a Connection URI (Alternative)
storage-method: MongoDB
data:
mongodb-connection-uri: 'mongodb://luckperms_user:YourPassword123!@83.168.94.0:27017/luckperms'
Connection String for Other Applications
mongodb://username:YourPassword123!@83.168.94.0:27017/database_name