|
| 1 | +.. _rm-prereq-mysql: |
| 2 | + |
| 3 | +=========================================== |
| 4 | +Configure Migration Prerequisites for MySQL |
| 5 | +=========================================== |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +To run sync jobs from a MySQL source database, the database may require |
| 14 | +some configuration changes. If Relational Migrator determines the |
| 15 | +database needs configuration changes, it automatically generates a |
| 16 | +SQL script with the required changes. It is recommended to have a |
| 17 | +Database Administrator (DBA) review the commands in this script and |
| 18 | +perform their execution on the database server. The |
| 19 | +MySQL Server configurations depend on the type of sync job: |
| 20 | + |
| 21 | +.. include:: /includes/fact-short-sync-job-desc.rst |
| 22 | + |
| 23 | +For details on supported versions of MySQL, see |
| 24 | +:ref:`supported-databases`. |
| 25 | + |
| 26 | +Steps |
| 27 | +----- |
| 28 | + |
| 29 | + |
| 30 | +.. tabs:: |
| 31 | + |
| 32 | + .. tab:: Snapshot Jobs |
| 33 | + :tabid: enable-snapshot-jobs |
| 34 | + |
| 35 | + .. procedure:: |
| 36 | + :style: normal |
| 37 | + |
| 38 | + .. include:: /includes/fact-my-sql-setup-user-permission-step.rst |
| 39 | + |
| 40 | + .. tab:: Continuous Jobs |
| 41 | + :tabid: enable-continuous-jobs |
| 42 | + |
| 43 | + Running continuous jobs on Relational Migrator |
| 44 | + requires the `binary log <https://dev.mysql.com/doc/refman/8.0/en/binary-log.html>`__ |
| 45 | + to be enabled on your MySQL instance. The binary log (Binlog) |
| 46 | + records all operations in the order they are committed to the |
| 47 | + database. |
| 48 | + |
| 49 | + .. procedure:: |
| 50 | + :style: normal |
| 51 | + |
| 52 | + .. include:: /includes/fact-my-sql-setup-user-permission-step.rst |
| 53 | + |
| 54 | + .. step:: (Optional) Manually verify Binlog is enabled |
| 55 | + |
| 56 | + Relational Migrator automatically checks this setting for |
| 57 | + you. To manually check the if the ``Binlog`` option is |
| 58 | + enabled, use the queries below for your version of MySQL: |
| 59 | + |
| 60 | + .. note:: |
| 61 | + |
| 62 | + ``Binlog`` is automatically enabled by default |
| 63 | + on MySQL ``8.x`` versions. |
| 64 | + |
| 65 | + .. tabs:: |
| 66 | + |
| 67 | + .. tab:: MySql 8.x |
| 68 | + :tabid: mysql-8x |
| 69 | + |
| 70 | + .. code-block:: sql |
| 71 | + :copyable: true |
| 72 | + |
| 73 | + SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::" |
| 74 | + |
| 75 | + FROM performance_schema.global_variables WHERE variable_name='log_bin'; |
| 76 | + |
| 77 | + .. tab:: MySql 5.x |
| 78 | + :tabid: mysql-5x |
| 79 | + |
| 80 | + .. code-block:: sql |
| 81 | + :copyable: true |
| 82 | + |
| 83 | + SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::" |
| 84 | + |
| 85 | + FROM information_schema.global_variables WHERE variable_name='log_bin'; |
| 86 | + |
| 87 | + .. step:: Locate and update the MySQL configuration file |
| 88 | + |
| 89 | + a. Run the following SQL query to get the ``server_id`` |
| 90 | + value for your MySQL instance: |
| 91 | + |
| 92 | + .. tabs:: |
| 93 | + |
| 94 | + .. tab:: MySql 8.x |
| 95 | + :tabid: mysql-8x |
| 96 | + |
| 97 | + .. code-block:: sql |
| 98 | + :copyable: true |
| 99 | + |
| 100 | + SELECT variable_value |
| 101 | + FROM |
| 102 | + performance_schema.global_variables |
| 103 | + WHERE variable_name='server_id'; |
| 104 | + |
| 105 | + .. tab:: MySql 5.x |
| 106 | + :tabid: mysql-5x |
| 107 | + |
| 108 | + .. code-block:: sql |
| 109 | + :copyable: true |
| 110 | + |
| 111 | + SELECT variable_value |
| 112 | + FROM |
| 113 | + information_schema.global_variables |
| 114 | + WHERE variable_name='server_id'; |
| 115 | + |
| 116 | + #. Locate the config file for your MySQL instance by running |
| 117 | + the following ``mysqld`` command in your terminal: |
| 118 | + |
| 119 | + .. tabs:: |
| 120 | + |
| 121 | + .. tab:: Windows |
| 122 | + :tabid: windows |
| 123 | + |
| 124 | + .. code-block:: |
| 125 | + :copyable: true |
| 126 | + |
| 127 | + mysql --help | findstr cnf |
| 128 | + |
| 129 | + .. tab:: MacOS / Linux |
| 130 | + :tabid: macos-linux |
| 131 | + |
| 132 | + .. code-block:: |
| 133 | + :copyable: true |
| 134 | + |
| 135 | + mysql --help | grep cnf |
| 136 | + |
| 137 | + #. Under the ``[mysqld]`` section of your MySQL |
| 138 | + configuration file add the following lines. Replace |
| 139 | + the ``XXXXX`` value with the ``server_id`` from the |
| 140 | + previous query: |
| 141 | + |
| 142 | + .. tabs:: |
| 143 | + |
| 144 | + .. tab:: MySql 8.x |
| 145 | + :tabid: mysql-8x |
| 146 | + |
| 147 | + .. code-block:: |
| 148 | + :copyable: true |
| 149 | + |
| 150 | + server-id = XXXXX |
| 151 | + log_bin = mysql-bin |
| 152 | + binlog_format = ROW |
| 153 | + binlog_row_image = FULL |
| 154 | + binlog_expire_logs_seconds = 864000 |
| 155 | + |
| 156 | + .. tab:: MySql 5.x |
| 157 | + :tabid: mysql-5x |
| 158 | + |
| 159 | + .. code-block:: |
| 160 | + :copyable: true |
| 161 | + |
| 162 | + server-id = XXXXX |
| 163 | + log_bin = mysql-bin |
| 164 | + binlog_format = ROW |
| 165 | + binlog_row_image = FULL |
| 166 | + expire_log_days = 10 |
| 167 | + |
| 168 | + .. note:: |
| 169 | + |
| 170 | + If you're running MySQL on AWS RDS and `automated backups |
| 171 | + <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html>`__ |
| 172 | + are not enabled, ``Binlog`` will be disabled, even if |
| 173 | + the values are set in the configuration file. |
| 174 | + |
| 175 | +Learn More |
| 176 | +---------- |
| 177 | + |
| 178 | +Relational Migrator relies on the open-source Debezium connector to |
| 179 | +capture row-level changes. For more details, see |
| 180 | +`Debezium MySQL <https://debezium.io/documentation/reference/stable/connectors/mysql.html>`__. |
0 commit comments