More about preparing a MySQL or MariaDB destination¶
Privileges¶
Why the user in Create the database and the user needs each privilege:
| Privilege | Why it's needed |
|---|---|
SELECT |
UPDATE and DELETE statements whose WHERE clause reads the key columns, and the Merge statements, which read the merge table and join it to the destination table. |
INSERT, UPDATE, DELETE |
Loading and applying changes. INSERT ... ON DUPLICATE KEY UPDATE needs both INSERT and UPDATE. |
CREATE |
CREATE TABLE for the destination tables, and for the SQDRWT_<id> merge tables of Merge groups. |
DROP |
DROP TABLE when a table is re-created, and TRUNCATE TABLE, which MySQL allows only with the DROP privilege: for Truncate table before replication and for emptying the merge tables. |
ALTER |
ALTER TABLE for primary keys, foreign keys and ALTER processing. |
INDEX |
CREATE INDEX and DROP INDEX. |
REFERENCES |
Only with Replicate Foreign Keys: MySQL 8.0 requires it on the parent table to create a foreign key. |
CREATE TEMPORARY TABLES |
Only for ADD Copy of ALTER processing in groups without checkpoint/restart. |
Tables you create yourself. With Use existing table for baseline, the Replicator Service never creates, alters,
drops or indexes the table. SELECT, INSERT, UPDATE and DELETE on it are then enough for Batch and
Sequence, plus DROP for Truncate table before replication (otherwise use Delete existing data before
replication). Merge still needs CREATE, DROP, SELECT, INSERT and DELETE on the connection's default
database for its merge tables. Create the index on the replication key yourself (see
The key at the destination).
Test the privileges¶
The privileges are first used when a subscription runs. When you create subscriptions, you can test them first with a
snapshot subscription of a small table. Its replication
events show each step and any MySQL error; command denied
to user names the statement that lacks a privilege.