Skip to content

Database

SOFe edited this page Apr 9, 2018 · 2 revisions

XialotEcon is powered by libasynql v3, which supports both SQLite3 databases (sqlite) and MySQL databases (mysql).

Database type

To choose the type of database to use, edit database.type in config.yml.

SQLite3 database

SQLite3 is stored in a single file. By default, the file is in plugins/XialotEcon/data.sqlite. Change the database.sqlite.file config to change the file location, where the path is relative to plugins/XialotEcon.

Do not put a slash in front of the path, unless you want to type an absolute path in your filesystem (e.g. /media/floppy/xialotecon.sqlite). For Windows users, paths starting with the drive name then a : are also resolved as absolute paths (e.g. C:/Users/Public/xialotecon.sqlite). Backslashes (\) and forward slashes (/) are treated as the same on Windows.

As of libasynql v3.0.0, you must install the sqlite3 extension in your PHP binaries to use SQLite3 databases.

  • If you use the official PocketMine-MP installer:
    • For Windows users: look at the bin/php/php.ini file
    • For MacOS/Linux users: look at the bin/php7/bin/php.ini file
    • Look for the lines starting with ;extension=. One of these lines should contain sqlite3, e.g. ;extension=sqlite3 or ;extension=php_sqlite3.dll (but not pdo_sqlite). Delete the ; in the beginning, then restart the server.
  • If you use PHP binaries from other sources:
    • Usually you should have the sqlite3 extension installed by default.
    • If you don't, and you can't figure it out yourself, use the official PocketMine-MP installer.

MySQL database

To use the MySQL database, you need to install a MySQL server. I don't suggest using a MySQL database unless you are going to access the database somewhere else (e.g. you have a website that uses data from XialotEcon, or you have other servers also running on XialotEcon). If you really want to use a MySQL database and you don't know how to install, google it yourself.

Create a user for XialotEcon (Avoid letting plugins use the root user). Create a schema dedicated for XialotEcon, and grant the XialotEcon users with full privileges to the schema. See this page for instructions to create a user, and this page for instructions to create a database.

Then enter your MySQL settings in database.mysql in config.yml.

As of libasynql v3.0.0, you must install the mysqli extension in your PHP binaries to use MySQL databases.

  • If you use the official PocketMine-MP installer:
    • For Windows users: look at the bin/php/php.ini file
    • For MacOS/Linux users: look at the bin/php7/bin/php.ini file
    • Look for the lines starting with ;extension=. One of these lines should contain mysqli, e.g. ;extension=mysqli or ;extension=php_mysqli.dll (but not pdo_mysql). Delete the ; in the beginning, then restart the server.
  • If you use PHP binaries from other sources:
    • Usually you should have the mysqli extension installed by default.
    • If you don't, and you can't figure it out yourself, use the official PocketMine-MP installer.

Avoid using the same MySQL schema in other plugins. The table names used in XialotEcon may clash with those used in other plugins, e.g. another plugin may also have an accounts table for different purposes.

Initialization

The SQLite3 database will be automatically created in in the path indicated in config.yml when you start the server, but you need to create the directories required.

The MySQL schema needs to be manually created according to the instructions above, but the tables in the schema will be created by the plugin automatically when you start the server.

Clone this wiki locally