Skip to content

Commit 3ef0c51

Browse files
authored
cloud/dm: add LOCK TABLES to source privilege prerequisites (#22598)
1 parent f013e32 commit 3ef0c51

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

tidb-cloud/migrate-from-mysql-using-data-migration.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,16 @@ For production workloads, it is recommended to have a dedicated user for data du
465465
| `RELOAD` | Global | Ensures consistent snapshots during full dump |
466466
| `REPLICATION SLAVE` | Global | Enables binlog streaming for incremental data migration |
467467
| `REPLICATION CLIENT` | Global | Provides access to binlog position and server status |
468+
| `LOCK TABLES` | Tables | Required when the source is a managed MySQL service (such as Amazon RDS, Aurora, ApsaraDB RDS for MySQL, Azure Database for MySQL, or Google Cloud SQL) where `FLUSH TABLES WITH READ LOCK` (FTWRL) is not permitted. In this case, DM falls back to `LOCK TABLES` to ensure consistency during full data export. Not required for self-managed MySQL instances where FTWRL is available. |
468469
469470
For example, you can use the following `GRANT` statement in your source MySQL instance to grant corresponding privileges:
470471
471472
```sql
473+
-- For self-managed MySQL:
472474
GRANT SELECT, RELOAD, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'dm_source_user'@'%';
475+
476+
-- For managed MySQL services (such as Amazon RDS and Aurora), also grant the LOCK TABLES privilege:
477+
GRANT SELECT, RELOAD, LOCK TABLES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'dm_source_user'@'%';
473478
```
474479

475480
#### Grant required privileges in the target <CustomContent plan="dedicated">{{{ .dedicated }}} cluster</CustomContent><CustomContent plan="essential">{{{ .essential }}} instance</CustomContent>

tidb-cloud/tidb-cloud-dm-precheck-and-troubleshooting.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ Failed to create a schema in the downstream TiDB cluster. This error means that
9494

9595
To resolve this issue, you can create a schema in the TiDB cluster based on a [supported collation](/character-set-and-collation.md#character-sets-and-collations-supported-by-tidb), and then resume the task by clicking **Restart**.
9696

97+
### Error message: "LOCK TABLES ... Access denied"
98+
99+
The full data export fails because the source database user does not have the `LOCK TABLES` privilege. This error typically occurs when migrating from a managed MySQL service (such as Amazon RDS, Aurora, ApsaraDB RDS for MySQL, Azure Database for MySQL, or Google Cloud SQL), where `FLUSH TABLES WITH READ LOCK` (FTWRL) is not permitted by the cloud provider. In this scenario, DM uses the default `consistency=auto` mode, which falls back to `LOCK TABLES` to ensure data consistency during full export. This operation requires the `LOCK TABLES` privilege.
100+
101+
> **Note:**
102+
>
103+
> This error can also occur on self-managed MySQL instances if FTWRL is unavailable for other reasons, such as a missing `RELOAD` privilege.
104+
105+
To resolve this issue, grant the `LOCK TABLES` privilege to the migration user on the source MySQL database:
106+
107+
```sql
108+
GRANT LOCK TABLES ON *.* TO 'dm_source_user'@'%';
109+
```
110+
111+
Then resume the task by clicking **Restart**.
112+
97113
## Alerts
98114

99115
You can subscribe to TiDB Cloud alert emails to be informed in time when an alert occurs.

0 commit comments

Comments
 (0)