MySQL Percona Galera Cluster with phpMyAdmin export

Galera Cluster have some limitations, for example all tables MUST have primary key.

In recent version, pxc_strict_mode is introduced to avoid unsupported features that can risk your data and server stability

One common trap is that SQL file exported with phpMyAdmin create index AFTER creating the table and inserting data.

During import, there is a transit state that table have no primary key and data need to insert to table, thus trigger the pxc_strict_mode error.

#1105 - Percona-XtraDB-Cluster prohibits use of DML command on a table (database.table) without an explicit primary key with pxc_strict_mode = ENFORCING or MASTER

Solution 1 (If you have SUPER permission):

On the beginning of SQL file, add

SET pxc_strict_mode=PERMISSIVE;

but you will likely receive another error depend on Percona Cluster version:

#1229 - Variable 'pxc_strict_mode' is a GLOBAL variable and should be set with SET GLOBAL

SET GLOBAL will do the job but it require SUPER permission. Remember to turn it back to ENFORCING after import.

Solution 2 (If you can re-export):

Re-export SQL file with “IF NOT EXISTS (less efficient as indexes will be generated during table creation)” option

As stated in it’s description, it have the side effect to create keys during table creation

Solution 3:

Edit SQL file and move all INSERT statements after index creation.

Dumb but useful if you can’t do any of above


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.