0

For MySQL 8.0.40 on Rocky Linux, my database currently uses the keyring plugin. I want to migrate to the keyring component. It shows

[ERROR] [MY-013106] [Server] Can not perform keyring migration : Failed to initialize destination keyring.

I am working from these resources:

I see someone had success setting encryption off, but I would like to avoid that.

I created the manifest: /usr/sbin/mysqld.my. It contains:

    {
      "components": "file://component_keyring_file"
    }

I checked that the component file exists:

ls /usr/lib64/mysql/plugin/component_keyring_file.so #success

I created the keyring configuration file: **/usr/lib64/mysql/plugin/component_keyring_file.cnf**. It reads:

    {
      "path": "/var/lib/mysql/mysql-keyring/component_keyring_file",
      "read_only": false
    }

I created the directory for the keyring file:

    mkdir /var/lib/mysql/mysql-keyring
    chown mysql:mysql /var/lib/mysql/mysql-keyring

After that, I stopped mysqld and tried to run the migration server. I have tried variations:

    mysqld --user=mysql --defaults-file=/etc/my.cnf --keyring-migration-to-component  --keyring-migration-source=keyring_file.so  --keyring-migration-destination=component_keyring_file.so
    
    mysqld --user=mysql --keyring-migration-to-component  --keyring-migration-source=keyring_file.so  --keyring-migration-destination=component_keyring_file.so

I understand that the migrating user cannot be root, so the user is mysql. Also, the component_keyring_file cannot be in the data directory. I have tried two paths:

/var/lib/mysql/mysql-keyring # dir for mysql files

/var/lib/mysql-keyring

I updated component_keyring_file.cnf and made sure the mysql user owned the directory.

1
  • One problem is the path of the keyring file. Use this command to look up the data directory: SELECT@@datadir; . I had to use a path like /var/lib/mysql-keyring/component_keyring_file. Anything under this path will fail: /var/lib/mysql/.... I also suspect there was a permission problem. The mysql user may need to own the keyring file and have write and execute permissions on it. I suspect it may need write and execute permissions on the parent directory. I have not confirmed this.
    – SMich
    Commented Nov 15 at 22:35

1 Answer 1

0

I was not able to run the migration from the command line. It returned errors like

[MV-013106] [Server] Can not perform keyring migration : Failed to initialize destination keyring.

I performed these steps to remove the keyring_file encryption, then enable the component keyfile encryption. This answer guided me.

  1. Disable encryption for each table using a script.
  2. Edit /etc/my.cnf to remove the early-plugin-load=keyring_file.so directive.
  3. Enable the component encryption:
  • Add the file component_keyring_file.cnf
  • Check ownership and write permissions on /var/lib/mysql-keyring/component_keyring_file.
  • Add the manifest, /usr/sbin/mysqld.my
  1. Restart the database and check the service status.

  2. Check the keyring component status.

    SELECT * FROM performance_schema.keyring_component_status;

  3. Enable encryption on each table using a script.

Script to generate Disable Encryption statements for a database.

SELECT
-- table_schema, table_name, table_type,
CONCAT( 'ALTER table `', table_name, '` ENCRYPTION = ''N''; ') AS alter_table
FROM information_schema.TABLES WHERE table_schema = 'database_name' AND table_type ='BASE TABLE';

Script to generate Enable Encryption statements for a database.

SELECT CONCAT( 'ALTER table `', table_name, '` ENCRYPTION = ''Y''; ') AS alter_table
FROM information_schema.TABLES WHERE table_schema = 'database_name' AND table_type ='BASE TABLE';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.