Starting with version 1.0.96, game servers in GSP-Panel can have databases associated with them. GSP-Panel has the ability to create and delete MySQL databases. Databases get created on the same server that hosts the GSP-Panel frontend, at this time it is not possible to manage remote MySQL installations.
To get started with this feature you will need to make sure your GSP-Panel MySQL user has the permissions below and you will need to configure the game template to allow for database creation and management by going to Configuration > Game Templates > Edit > General > Database Settings.
In order for GSP-Panel to create databases and users you will need to make sure the GSP-Panel MySQL user has the permissions listed below. Please note in most cases this feature will not work on shared web hosting as a result of needing these permissions.
- GRANT privileges
- CREATE USER privileges
- SHOW DATABASES privileges
- SELECT privileges for mysql.user
These permissions can typically be granted with the following SQL query, replace YOURDBUSER with the user that GSP-Panel uses for MySQL access.
GRANT SELECT, SHOW DATABASES, CREATE USER ON *.* TO 'YOURDBUSER'@'localhost' REQUIRE NONE WITH GRANT OPTION;
Technical Bits / How the feature works
When a database creation is requested the following happens:
- The requested database name is cleansed, only allowing for a-z, A-Z, 0-9, and a certain unicode range supported by MySQL
- The database is then created which is prefixed by gsp_[gameserver ID]_ (e.g. gsp_2290_mydatabase)
- After the database is created GSP-Panel checks to see if this gameserver already has a SQL user
- If a user already exists then we proceed to step 4
- If a user does not exist then one is created using the gspuser_[gameserver ID] structure (e.g. gspuser_2290), in this case a random password is generated
- Once the user is added then privileges are then granted to the database
When a database removal is requested the following happens:
- Database is deleted
- If this is the last database for the game server then the database user is deleted
- Databases are not backed up by GSP-Panel
- Databases can only be created on the frontend server
- This feature will likely not work on shared web hosting