Minecraft - Databases

Post Reply
User avatar
LHammonds
Site Admin
Site Admin
Posts: 525
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Minecraft - Databases

Post by LHammonds » Thu Jul 24, 2014 1:22 pm

Info on setting up an existing MySQL database to let a plugin connect to it:
  1. You must create a database.
  2. You must create a login account.
  3. You must grant permissions for that login account to that database.
  4. You update your plugin configuration to specify the MySQL database server name/ip, the database name, user ID and user password.
  5. Most plugins will create the tables and populate the data as long as you have done the prior steps.
How you do all of these depends on the tools you use. If you have access to the server command prompt where the database is installed, you can run the mysql command-line. If you access the database using PhpMyAdmin, then you can run queries inside that. If you are running MySQL on a Windows machine and you have WorkBench installed, you can use that utility. I'm sure there are several other ways as well and depending on how you connect will decide the exact steps you take.

Creating the database and user accounts are the super easy parts that are extremely easy to find via Google.

The step to grant permission can require a bit more knowledge of how your server is setup and can determine if you pass or fail in your connection attempt. For example, if your MySQL database is run on the same server as your Minecraft server, then you can grant access for the user ID to the database as "local only" access. If your database is on a different server, you can grant access for the user ID to that database for "that server name" only...meaning the user ID is only allowed to connect from your specified minecraft server machine/IP. Another option is to grant access for that user ID to the database as "global" access meaning that ID can connect to the database from anywhere in the world...which is typically not as secure but can be handy if your machine name changes or you have multiple servers that connect to the same database and you use the same ID.

Here are some examples of SQL syntax for setting up a database called "minecraft" with an ID of "minecraftuser" and password of "mypass123" but I STRONGLY suggest you never use this exact ID/pass combo now that the entire world knows about it.

Example #1 - Database and Minecraft on same machine

Code: Select all

CREATE DATABASE minecraft;
CREATE USER 'minecraftuser'@'localhost' IDENTIFIED BY 'mypass123';
GRANT ALL PRIVILEGES ON minecraft TO 'minecraftuser'@'localhost';
FLUSH PRIVILEGES;
Example #2 - Minecraft on separate machine called srv-minecraft

Code: Select all

CREATE DATABASE minecraft;
CREATE USER 'minecraftuser'@'srv-minecraft' IDENTIFIED BY 'mypass123';
GRANT ALL PRIVILEGES ON minecraft TO 'minecraftuser'@'srv-minecraft';
FLUSH PRIVILEGES;
Example #3 - User ID able to login to database from anywhere

Code: Select all

CREATE DATABASE minecraft;
CREATE USER 'minecraftuser'@'%' IDENTIFIED BY 'mypass123';
GRANT ALL PRIVILEGES ON minecraft TO 'minecraftuser'@'%';
FLUSH PRIVILEGES;

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest