Minecraft MPDB Setup

Last Edit: 2024.07.30

Debian / Ubuntu

Overview

Setup the MySQL Player Data Bridge (MPDB) plugin on a PaperMC Minecraft server.

Assumptions

Setup Database

Open a MariaDB session as an administrative user. Enter the password when prompted.

mariadb -u sqladmin -p

Create Database

Create a new database named mpdb.

CREATE DATABASE IF NOT EXISTS mpdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;

Create User

Create a SQL user to access the mpdb database: mpdbuser. When generating a password, keep it at 41 characters with the mysql_native_password plugin.

CREATE USER 'mpdbuser'@'localhost' IDENTIFIED BY 'Generated_Secure_Password';

Database Permissions

Grant the mpdbuser user access to the mpdb database.

GRANT ALL PRIVILEGES ON mpdb.* TO 'mpdbuser'@'localhost';

Plugin Setup

Download and Install the MySQL Player Data Bridge plugin.

Download MySQL Player Data Bridge

Download the MySQL Player Data Bridge plugin on SpigotMC.

Upload the file to the server using SCP, SFTP, or SSH. If using a hosting provider, you may be able to do this with the web interface.

The following command is an example using scp, replace the values as required.

  • $HOME/Downloads/MysqlPlayerDataBridge-v4.11.0.jar: Path to the plugin file, verify it and the version number are correct.
  • serveruser: User with SSH capabilities on the Minecraft server.
  • 192.168.1.255: Hostname or IP address of the server.
  • /tmp: Where to copy file, this guide will assume it is copied to the /tmp directory.
  • -i $HOME/.ssh/path-to-private-key: Private key file to use for authentication.

Password Example

scp $HOME/Downloads/MysqlPlayerDataBridge-v4.11.0.jar [email protected]:/tmp

Private Key Example

scp $HOME/Downloads/MysqlPlayerDataBridge-v4.11.0.jar [email protected]:/tmp -i $HOME/.ssh/path-to-private-key

Install MySQL Player Data Bridge

On the Minecraft server, copy the plugin file to the plugins directory within the Minecraft server directory.

cp /tmp/MysqlPlayerDataBridge-v4.11.0.jar /opt/minecraft/server/plugins/

Modify the file permissions as required.

chown minecraft:minecraft /opt/minecraft/server/plugins/MysqlPlayerDataBridge-v4.11.0.jar
chmod 640 /opt/minecraft/server/plugins/MysqlPlayerDataBridge-v4.11.0.jar

Restart Minecraft to generate the configuration files for MySQL Player Data Bridge.

sudo systemctl stop minecraft && sudo systemctl start minecraft

Configure MPDB

Open the MPDB configuration file in an editor. The configuration file is well-commented and should be reviewed fully to get the most out of the plugin. Find the config.yml file in the plugins/MysqlPlayerDataBridge directory.

nano /opt/minecraft/server/plugins/MysqlPlayerDataBridge/config.yml

Database

Configure the database based on the information used to create the database in MariaDB. Refer to the following table for notable settings.

SettingValueDescription
host127.0.0.1Hostname or IP address of database, leave unchanged when the database is on the same system.
port3306Default SQL port, leave unchanged unless a different port is specified by a vendor.
databaseNamempdbThe name of the created database.
usermpdbuserUsername of the created MariaDB SQL user.
passwordGenerated_Secure_PasswordPassword for the specified user.
sslEnabledfalseLeave disabled on localhost, when connecting to a remote database it is highly recommended. Requires the database host to support SSL.

The following is an example database configuration.

database:
  mysql:
    #MySQL server address
    host: 127.0.0.1
    #MySQL server port (default 3306)
    port: 3306
    #Database name (NOTE! You need to create the database, then the plugin will create the tables.)
    databaseName: 'mpdb'
    #Tables names (the plugin will auto create them)
    TablesNames:
      #Inventory and Armor table name.
      inventoryTableName: 'mpdb_inventory'
      #Enderchest table name.
      enderchestTableName: 'mpdb_enderchest'
      #Experience table name.
      experienceTableName: 'mpdb_experience'
      #PotionEffects table name.
      potionEffectsTableName: 'mpdb_potionEffects'
      #Health, food and air table name.
      healthFoodAirTableName: 'mpdb_health_food_air'
      #Location table name.
      locationTableName: 'mpdb_location'
      #Economy table name.
      economyTableName: 'mpdb_economy'
    #User name
    user: 'mpdbuser'
    #User password
    password: 'Generated_Secure_Password'
    #SSL connection
    sslEnabled: false
  #This maintenance task runs async with a 2 min delay after the server starts.
  removeOldAccounts:
    #Enable or disable database clean up of old accounts. | (true or false)
    enabled: false
    #Inactivity in days. Default 60 days.
    inactivity: 360

New Players Commands

Example player commands will be present after generating the configuration file. These commands will run the first time a player joins the server.

Modify, remove, or add any desired commands.

New-Players-Cmd:
- 'tell <PlayerName> Cmd 1 sample - you should remove this from the MPDB config'
- 'tell <PlayerName> Cmd 2 sample - you should remove this from the MPDB config'

References

1 2 3 4 5 6


  1. brunyman. “MySQL Player Data Bridge.” 2023. ↩︎

  2. brunyman. “MPDB GitHub.” 2020. ↩︎

  3. Fandom. “Minecraft Wiki.” 2024. ↩︎

  4. MariaDB. “MariaDB Documentation.” 2024. ↩︎

  5. MariaDB. “MariaDB Knowledge Base.” 2024. ↩︎

  6. Oracle. “MySQL Documentation.” 2024. ↩︎