ChatGPT is the hottest topic in the tech world right now. One story even says that ChatGPT has passed Google’s Level 3 programming interview.  I wondered, does that mean ChatGPT is ready to replace MySQL DBAs, too? No. Let me show you why.

Recently, one of our clients was considering encrypting their data at rest using the Percona file-based keyring plugin. To make the process more secure, they considered removing the local keyring_file after MySQL started. So even if someone gets host access, the data files are still protected because they do not have access to the master key used to encrypt the keys for the tables running Encryption at Rest.

Let ChatGPT try its hand at MySQL administration

Let’s see what ChatGPT will say.

I asked ChatGPT the question: “Can we backup and then remove the keyring file used for encryption at rest plugin after MySQL starts?

The answer from ChatGPT:No, it is not recommended to remove the keyring file used for the encryption at rest plugin while MySQL is running, as this can lead to data corruption or unexpected behavior. The keyring file is an important part of the encryption at rest plugin and is used to securely store encrypted information, such as passwords and other sensitive data.

To safely make changes to the keyring file, it is recommended to stop the MySQL service, back up the file, and then make any necessary modifications or deletions. Once the changes have been made, you can start the service again.

Failing to stop the MySQL service before making changes to the keyring file can result in data loss or corruption, and it may not be possible to recover the data. To ensure the safety and integrity of your data, it is important to follow the recommended procedure of stopping the service, backing up the file, and making any necessary changes.

The answer looks so correct at first glance and seems very reasonable if you don’t have enough experience working on the Percona file-based keyring plugin. In fact, the answer is only partially correct or even entirely wrong in many places

First, we can remove the keyring file used for the encryption at rest plugin while MySQL is running. The plugin will still work as normal, to encrypt a new table, to decrypt the contents of encrypted tables, without corruption, or unexpected behavior. 

This is because the keyring plugin on startup loads the entire content of the keyring_file (i.e., key id, key user, key type, together with keys themselves) into the cache, unless MySQL is restarted, or you want to rotate the master key (you won’t though, as you know you have removed the keyring_file), it will not need the keyring file anymore. We can verify that through the following example:

  • We started MySQL with the configuration of  “early-plugin-load=keyring_file.so and keyring_file_data=/var/lib/mysql/keyring_file” to enable the Keyring_file plugin. When MySQL started, it created an empty file /var/lib/mysql/keyring_file. However, when we then create a table using ENCRYPTION=’Y’, we can see that the file /var/lib/mysql/keyring_file is not empty anymore. This is because the Keyring_file plugin has created a master key putting all the information in memory and saving a backup copy of the data into the file /var/lib/mysql/keyring_file.

  • We backed up and then removed the file keyring_file without restarting MySQL. MySQL is still running fine, we can select from the encrypted table, and we can also create a new table with ENCRYPTION=’Y’; everything works the same as before we removed the file keyring_file 

  • We restarted MySQL, and found out MySQL started with errors complaining ”[InnoDB] Encryption can’t find master key, please check the keyring is loaded.”. But it created another empty file /var/lib/mysql/keyring_file after restarting. Now, we couldn’t do any operation on the encrypted tables since it will report the error, even if we copy the backup file  /var/lib/mysql/keyring_file_1 to override the file /var/lib/mysql/keyring_file without restarting.

  • We restarted MySQL again, with the backup file  /var/lib/mysql/keyring_file_1 overriding the file /var/lib/mysql/keyring_file. Now everything is back to normal.

Second, we are not supposed to make any changes to the keyring file. Instead, we are supposed to rotate the key via the plugin, and we need to back up the key before we rotate it. However, the answer provided by ChatGPT implies that we can make some changes to the keyring file, which is terribly wrong.

Conclusion

ChatGPT may provide only partially correct, or even worse, entirely wrong, answers to your question, which still requires expertise to double-check the correctness. Compared to the other search engines, which provide possible links to the answer to your question, relying on expertise to see which one is useful, and/or how to use the information. You will have to have a DBA for your MySQL database no matter with ChatGPT and/or other search engines.

P.S.: When I was done with the blog, I asked the ChatGPT again, and here was what I got:

Ask: “Can we back up and then remove the keyring file, which is used for the Percona plugin of encryption at rest, after MySQL starts?”

ChatGPT: ”Yes, you can backup and then remove the keyring file used by the Percona encryption at rest plugin after MySQL has started. However, removing the keyring file will result in loss of encryption for data at rest, so it is important to make sure that you have backed up the encryption key and have a plan for re-encrypting the data before removing the keyring file to prevent data loss or corruption.

Ask:Can we back up and remove the keyring file used for encryption at rest plugin after MySQL starts?

ChatGPT: “Yes, it is possible to backup and remove the keyring file used for encryption at rest plugin after MySQL has started. However, removing the keyring file will result in loss of encryption for data at rest, so it is important to backup the encryption key and have a plan for re-encrypting the data before removing the keyring file to avoid data loss or corruption.

The next day, I got another answer again:

Ask:Can we back up and remove the keyring file, which is used for the Percona plugin of encryption at rest, after MySQL starts?”

ChatGPT:The keyring file is an important component of the Percona encryption at rest plugin, and it is used to securely store encryption keys. Backing up the keyring file before removing it would ensure that you have a copy of the encryption keys and would be able to restore them if necessary. However, removing the keyring file while MySQL is running is not recommended, as it could cause unexpected behavior or data corruption. It is important to stop MySQL and back up the keyring file before removing it to avoid any potential issues.”

So, ChatGPT may give different answers to the same question at different times. It makes ChatGPT more unreliable, especially if you want it to be your DBA. In fact, people ask questions to ChatGPT and vote ? or ? next to the answer to help the AI learn. In other words, we are looking at an alpha version, and we are helping it become better.

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Fernando Mario

Interesting topic (the GPT stuff). I wonder what can happen in 10 years or so.

Igor Solodovnikov

I would try to put the text of this blog post into ChatGPT and then ask the same question again.