Changing the database

Intro

Zyno Bot allows you to use two types of databases: MySQL and ValueSaver. The main difference between the two is that MySQL saves all the data externally from your bot (in most cases on a different server as well) and ValueSaver saves all the data as JSON files locally in your bot's folder. These are all the most important differences between these database types:

Differences

Choosing a database

Based on the differences described above, you can make the consideration of changing your database to MySQL or keeping it to ValueSaver (which is the default database type).

From ValueSaver to MySQL

If you decide to change your database type to MySQL, it is important to follow these steps, since you can end up losing the data which has been saved on the ValueSaver database.

To start with the transfer, you need to open your config.json file. At the bottom of your configuration file, you can find the following part:

...
    "database": {
        "type": "ValueSaver",
        "mysql": {
            "host": null,
            "user": null,
            "password": null,
            "database": null
        }
    },
...

At this part you will need to provide the login credentials to your MySQL database. Without these credentials, the bot is unable to login to your database and store the values. You need to provide the following values:

  • host: The IP where your database is being hosted. If you host your database on the same server, you can set it to "localhost".

  • user: The username of the account you use to login to your database.

  • password: The password of the account you use to login to your database.

  • database: The name of the database where your bot needs to store the data.

Do not change the type value! By changing this, your bot is unable to transfer the existing data to your new MySQL database.

Now you've changed these values, you need to save the config.json file and restart your bot. By restarting the bot, the bot will receive the new database login credentials. Once your bot has been restarted, you can transfer your existing data to your new MySQL database by executing the /admin command with the Move to different database option. When you execute this command, the bot will display a message with a select menu. The select menu includes two database options: MySQL and ValueSaver. To transfer the data, you would now need to select the MySQL option. After you've selected this option, the bot will automatically transfer all the existing data to the new MySQL database which you've just added in the config.json file. Transfering this can take a while since the bot has to convert each value and each table to a readable value for your MySQL database. The message which your bot edited after you've selected the MySQL option in the select menu will automatically update once the bot has successfully transfered all the data.

While the bot is transfering the data, it is not possible to use your bot. Otherwise the transfer process could be interupted when the ValueSaver database gets updated as a result of something happening in your server.

Once the bot has completed the transfer, the previously sent message will update and tell you it's done transfering the data. You do not need to change the type value in your config.json file since the bot has already done this for you. Everything will from then on be saved in your MySQL database.

MySQL to ValueSaver

The transfer process of a MySQL database to a ValueSaver database is way easier. The reason for this is that everything which has been saved in your MySQL database, automatically gets cached in your Discord bot. Therefore your bot doesn't need to import any data anymore from your MySQL database when you decide to transfer the data to a ValueSaver database. To change the database type to a ValueSaver database, you need to execute the /admin command with the Move to different database option. The bot will then send a message with a select menu. The select menu includes two database options: MySQL and ValueSaver. To transfer the data, you would now need to select the ValueSaver option. Like explained before, the bot has already cached the data of your MySQL database. Therefore this transfer process is way faster than transferring the data from a ValueSaver database to a MySQL database.

When you select the ValueSaver option in the select menu, the transfer will start. The same message of the select menu will then change once the transfer has been completed.

Last updated