# Vorbereitung zur Migration auf Percona XtraDB Cluster Um eine vorhandene MySQL Datenbank zu Percona XtraDB Cluster zu migrieren müssen einige Voraussetzungen erfüllt sein (siehe hierzu auch die [Limitations](https://www.percona.com/doc/percona-xtradb-cluster/LATEST/limitation.html "https://www.percona.com/doc/percona-xtradb-cluster/LATEST/limitation.html")-Seite bei Percona.
-
Alle Tabellen müssen InnoDB Engine sein
-
Jede Tabelle sollte einen PRIMARY KEY haben
#### Alle Tabellen finden, die nicht die InnoDB Engine verwenden ``` USE information_schema; SELECT CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS TABLES_NOT_INNODB FROM TABLES WHERE ENGINE != 'InnoDB' AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema'); ``` #### Tabellen ohne PRIMARY KEY finden Dies verhindert folgenden Fehler beim Import eines Dumps: ``` [ERROR] WSREP: Percona-XtraDB-Cluster prohibits use of DML command on a table (db.taxonomy_index) without an explicit primary key with pxc_strict_mode = ENFORCING or MASTER ERROR 1105 (HY000) at line 20655: Percona-XtraDB-Cluster prohibits use of DML command on a table (db.taxonomy_index) without an explicit primary key with pxc_strict_mode = ENFORCING or MASTER ``` ``` USE information_schema; SELECT CONCAT(TABLES.TABLE_SCHEMA, '.', TABLES.TABLE_NAME) AS TABLES_WITHOUT_PRIMARY_KEY FROM TABLES LEFT JOIN KEY_COLUMN_USAGE AS c ON (TABLES.TABLE_NAME = c.TABLE_NAME AND c.CONSTRAINT_SCHEMA = TABLES.TABLE_SCHEMA AND c.CONSTRAINT_NAME = 'PRIMARY') WHERE TABLES.TABLE_SCHEMA <> 'information_schema' AND TABLES.TABLE_SCHEMA <> 'performance_schema' AND TABLES.TABLE_SCHEMA <> 'mysql' AND c.CONSTRAINT_NAME IS NULL; ``` Über ALTER TABLE läßt sich diesen Tabellen ein PRIMARY KEY zuweisen. Vorher sollte allerdings sichergestellt sein, dass die Applikation auch damit zurecht kommt. PRIMARY KEY hinzufügen: ``` USE mydb; ALTER TABLE address ADD id INT PRIMARY KEY AUTO_INCREMENT; ```