Before using a self-managed MySQL database as a DTS source, create a database account and enable binary logging. Both are required to pass the precheck for incremental migration, synchronization, or change tracking.
Prerequisites
-
MySQL 5.6 or later
-
Access to the MySQL configuration file (
my.cnfon Linux,my.inion Windows) -
Root or admin privileges on the MySQL server
-
Ability to restart the MySQL service
Required permissions
DTS requires these permissions for incremental migration, synchronization, and change tracking:
|
Permission |
Purpose |
|
SELECT |
Read data from objects to migrate, synchronize, or track |
|
REPLICATION CLIENT |
Read the binary log position |
|
REPLICATION SLAVE |
Read binary log events |
|
SHOW VIEW |
Read view definitions |
|
CREATE on |
Create a database named |
Step 1: Create the database account
-
Connect to the self-managed MySQL database.
-
Create a dedicated account for DTS.
CREATE USER 'username'@'host' IDENTIFIED BY 'password';Parameter
Description
usernameAccount name to create
hostAllowed login host. Use
%for any host.passwordPassword for the account
-
Grant the required permissions.
Grant permissions on the databases and tables to migrate:
GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;Grant the CREATE permission:
GRANT CREATE ON *.* TO 'username'@'host' WITH GRANT OPTION;Parameter
Description
privilegesSELECT, INSERT, UPDATE, or ALL
databasenameDatabase name. Use
*for all databases.tablenameTable name. Use
*for all tables.usernameAccount to grant permissions to
hostAllowed login host. Use
%for any host.WITH GRANT OPTIONOptional. Lets the account grant permissions to others.
Example: Create an account
dtsmigrationwith full permissions:CREATE USER 'dtsmigration'@'%' IDENTIFIED BY 'Dts123456'; GRANT ALL ON *.* TO 'dtsmigration'@'%'; -
Verify the account permissions.
SHOW GRANTS FOR 'dtsmigration'@'%';The output should include
GRANT ALL PRIVILEGES ON *.* TO 'dtsmigration'@'%'.
Step 2: Configure binary logging
Binary logging changes require a MySQL restart. Plan this during off-peak hours.
Binary logging parameters
|
Parameter |
Required value |
Description |
|
|
|
Enables binary logging and sets the log file prefix. |
|
|
|
Records row-level changes. STATEMENT and MIXED formats may cause data inconsistencies. |
|
|
Integer greater than 1 (example: |
Unique identifier for the server in a replication topology. |
|
|
|
Logs full before-and-after images of each row. Required for MySQL versions later than 5.6. |
|
|
|
Log retention in days. MySQL versions earlier than 8.0 only. Default: |
|
|
|
Log retention in seconds. MySQL 8.0 and later only. Default: |
|
|
|
Logs replicated events to the local binary log. Required for dual-primary clusters only. |
Edit the configuration file
-
Open the MySQL configuration file.
-
Linux: Edit my.cnf with
vimor another editor.vim /path/to/my.cnfNotemy.cnflocation varies by distribution. Common paths:/etc/my.cnf,/etc/mysql/my.cnf,/etc/mysql/mysql.conf.d/mysqld.cnf. -
Windows: Open my.ini in a text editor.
-
-
Add or modify these parameters under the
[mysqld]section:log_bin=mysql_bin binlog_format=row server_id=2 binlog_row_image=full -
Set the binary log retention period.
MySQL 5.7 and earlier:
expire_logs_days=7Noteexpire_logs_daysis deprecated in MySQL 8.0 and later.MySQL 8.0 and later:
binlog_expire_logs_seconds=604800 -
(Optional) For dual-primary cluster deployments, add:
log_slave_updates=ON -
Restart the MySQL service.
-
Linux:
/etc/init.d/mysqld restart -
Windows: Use Services Manager or run:
net stop mysql net start mysql
-
Verify binary logging
After restarting, connect to MySQL and verify the settings:
SHOW VARIABLES LIKE 'log_bin';
-- Expected: log_bin | ON
SHOW VARIABLES LIKE 'binlog_format';
-- Expected: binlog_format | ROW
SHOW VARIABLES LIKE 'binlog_row_image';
-- Expected: binlog_row_image | FULL
SHOW VARIABLES LIKE 'server_id';
-- Expected: server_id | <integer greater than 1>