Skip to content

Commit cb2598e

Browse files
authored
dm: add LOCK TABLES privilege note for managed MySQL sources (#22605)
1 parent 1232ec5 commit cb2598e

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

dm/dm-precheck.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@ For the full data migration mode (`task-mode: full`), in addition to the [common
6767

6868
* (Mandatory) dump permission of the upstream database
6969

70-
- SELECT permission on INFORMATION_SCHEMA and dump tables
71-
- RELOAD permission if `consistency=flush`
72-
- LOCK TABLES permission on the dump tables if `consistency=flush/lock`
70+
- `SELECT` permission on `INFORMATION_SCHEMA` and dump tables
71+
- `RELOAD` permission if `consistency=flush`
72+
- `LOCK TABLES` permission on the dump tables if `consistency=lock`
73+
74+
> **Note:**
75+
>
76+
> When `consistency=auto` (the default), DM first tries `FLUSH TABLES WITH READ LOCK` (FTWRL). If FTWRL is unavailable, DM falls back to `LOCK TABLES`. This fallback commonly occurs on managed MySQL services (such as Amazon RDS, Aurora, ApsaraDB RDS for MySQL, Azure Database for MySQL, and Google Cloud SQL), where FTWRL is not permitted. In this case, the `LOCK TABLES` privilege is required at runtime, but the precheck does not currently verify this privilege. For the full list of privileges, see [DM-worker privileges](/dm/dm-worker-intro.md#upstream-database-user-privileges).
7377
7478
* (Mandatory) Consistency of upstream MySQL multi-instance sharding tables
7579

dm/dm-worker-intro.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,23 @@ The upstream database (MySQL/MariaDB) user must have the following privileges:
5252
| `REPLICATION SLAVE` | Global |
5353
| `REPLICATION CLIENT` | Global |
5454

55+
> **Note:**
56+
>
57+
> If you migrate 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, also grant the `LOCK TABLES` privilege. With the default `consistency=auto` setting, DM falls back to `LOCK TABLES` when FTWRL is unavailable.
58+
5559
If you need to migrate the data from `db1` to TiDB, execute the following `GRANT` statement:
5660

5761
```sql
5862
GRANT RELOAD,REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'your_user'@'your_wildcard_of_host';
5963
GRANT SELECT ON db1.* TO 'your_user'@'your_wildcard_of_host';
6064
```
6165

66+
For managed MySQL services where `FLUSH TABLES WITH READ LOCK` (FTWRL) is not permitted, also grant the `LOCK TABLES` privilege:
67+
68+
```sql
69+
GRANT LOCK TABLES ON db1.* TO 'your_user'@'your_wildcard_of_host';
70+
```
71+
6272
If you also need to migrate the data from other databases into TiDB, make sure the same privileges are granted to the user of the respective databases.
6373

6474
### Downstream database user privileges

dm/quick-start-with-dm.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ You can use Docker to quickly deploy a test MySQL 8.0 instance.
9191
GRANT PROCESS, BACKUP_ADMIN, RELOAD, REPLICATION SLAVE, REPLICATION CLIENT, SELECT ON *.* TO 'tidb-dm'@'%';
9292
```
9393

94+
> **Note:**
95+
>
96+
> If your MySQL source is a managed MySQL service (such as Amazon RDS, Aurora, ApsaraDB RDS for MySQL, Azure Database for MySQL, or Google Cloud SQL), also grant the `LOCK TABLES` privilege. For more information, see [DM-worker privileges](/dm/dm-worker-intro.md#upstream-database-user-privileges).
97+
9498
4. Create sample data:
9599

96100
```sql
@@ -148,6 +152,10 @@ On macOS, you can quickly install and start MySQL 8.0 locally using [Homebrew](h
148152
GRANT PROCESS, BACKUP_ADMIN, RELOAD, REPLICATION SLAVE, REPLICATION CLIENT, SELECT ON *.* TO 'tidb-dm'@'%';
149153
```
150154

155+
> **Note:**
156+
>
157+
> If your MySQL source is a managed MySQL service (such as Amazon RDS, Aurora, ApsaraDB RDS for MySQL, Azure Database for MySQL, or Google Cloud SQL), also grant the `LOCK TABLES` privilege. For more information, see [DM-worker privileges](/dm/dm-worker-intro.md#upstream-database-user-privileges).
158+
151159
6. Create sample data:
152160

153161
```sql

0 commit comments

Comments
 (0)