MySQL Databases Explained

### What is a MySQL Database?

Minecraft plugins often need to save data somewhere. For instance, if you use a plugin that allows players to set homes and teleport to them later then the plugin must save the player's name, the home name, and the coordinates for that home in order to retrieve that information later when the player wants to teleport to it. Most plugins will store their plugin data within the plugin folder under the name of the plugin. If we use a plugin called "Essentials" then it would store data in the "Plugins" folder and under the "Essentials" sub-folder. Normally, this is sufficient and we have no real need for a MySQL database. There are a few cases, however, where a plugin may need to store huge amounts of data (I.e. 25+ Gigabytes). In those cases it is best to use a MySQL database because it will store it outside of your server's normal files and it will access the data more quickly too!

### Pros & Cons

There are benefits and downsides to using a MySQL database. It is recommended to use the default storing method for most plugins. The only plugins I'd recommend using a MySQL database for are ones that take up a lot of disk space over time (I.e. CoreProtect or world mapping plugins).

#### Pros of using a MySQL Database

1. Minecraft Hosts limit how much disk space your server can use. Using a MySQL database will have any data within it not count toward that limit usually.
2. Server backups will not take as long and will not take up as much space.
	* This can mean the difference between a server backup taking 25 GB and 6 hours **vs** 50+ GB and 12+ hours.
	* If you only use MySQL databases for data that is optional to backup (such as CoreProtect or world mapping plugins) then you don't need to create MySQL database backups.

#### Cons of Using a MySQL Database

1. If you decide to switch Minecraft hosts you'll need to learn how to backup your MySQL database to your computer then upload it to your new MC host's MySQL database (if you need the data on your new MC host).
2. If you use a MySQL database for plugins storing important data like set homes, warps, the spawn point, etc then you should backup MySQL manually yourself periodically. This requires learning how to backup your MySQL database to your computer. However, as long as you're only using a MySQL database for optional data such as CoreProtect or world mapping plugins then you don't really need to back it up.

### Security Warning

When you create a MySQL database it will provide you a username, password, hostname (or endpoint) with an IP:Port, and possibly a URL. This information should then be copy/pasted into your plugin's config.yml file where it requests that information. Be sure to never share these credentials with anyone! If you share your config.yml file when asking for help on forums or Discord servers then be sure to remove your MySQL database details before providing the files. If someone obtains your credentials they may be able to abuse them to gain OP on your server or cause other major problems depending on the type of plugins you have connected to your MySQL database.

### Creating a MySQL Database

Minecraft hosts will allow you to create MySQL databases using their server panel. Your Minecraft host is likely using Multicraft or Pterodactyl as their panel software. Use the relevant guide below to create a MySQL database. If you don't know which panel your MC host uses then you may create a ticket and ask them or check both guides and see which looks closer to what you see on your MC host's website.

MySQL Databases in Multicraft

MySQL Databases in Pterodactyl