mattintosh note

どこかのエンジニアモドキの備忘録

AWS RDSにmysqldump: Couldn't execute 'FLUSH TABLES WITH READ LOCK': Access denied for userが出て接続できなくなった

mysqldump のバージョンを上げたせいか AWS RDS で運用してるデータベースのダンプを取ろうとすると下記のメッセージが出てダンプが取れなくなった。尚、mysql コマンドでは接続できる。

mysqldump: Couldn't execute 'FLUSH TABLES WITH READ LOCK': Access denied for user 'admin'@'%' (using password: YES) (1045)

使用中のバージョンはこれ。

mysqldump Ver 8.0.32 for macos11.7 on x86_64 (Homebrew)

前々から MySQL 8.x 系のクライアントから 5.7 系とかのダンプを取るには --skip-column-statistics--single-transaction を付けていて問題なかったけど最近になって --single-transaction が有効だと上のメッセージが出てダンプが取れなくなってしまった。

異なるいくつかのデータベースに対しても同じメッセージが出るので RDS 側の仕様の変更なのか手元の mysqldump のバージョンの変更なのかどちらかなんだろうけど 5.7 系 mysqldump だと --single-transaction 付けていても問題ないので 8.x 系のクライアントの問題な気がする。

もともと AWS RDS では FLUSH TABLES WITH READ LOCK が許可されていなかったがこれまでは問題なかった。

aws.amazon.com

最近の話題で調べてみたら Tanaka Tsubasa さんがバグとして上げてくれていた。8.0.32 で挙動が変わって --single-transaction で FLUSH TABLES WITH READ LOCK を使うようになったらしい。

bugs.mysql.com

Homebrew には mysql-client@5.7 パッケージがあるので


2023/03/09 追記

8.0.33 で gtid_mode=ON--set-gtid-purged=ON|AUTO の場合に FLUSH_TABLES が入るように変更されたようです。--set-gtid-purged=OFF なら大丈夫そうかな(Homebrew にまだ落ちてきてないので未確認)。

[21 Feb 22:20] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Server 5.7.42 / 8.0.33 releases, and here's the proposed changelog entry from the documentation team:

5.7.42:
With mysqldump, using --single-transaction required either the RELOAD or
FLUSH_TABLES privilege with mysqldump v5.7.41. This requirement now only
applies when gtid_mode=ON (defaults to OFF) and with --set-gtid-purged =
ON|AUTO (defaults to AUTO).

8.0.33:
With mysqldump, using --single-transaction required either the RELOAD or
FLUSH_TABLES privilege with mysqldump v8.0.32. This requirement now only
applies when gtid_mode=ON (defaults to OFF) and with --set-gtid-purged =
ON|AUTO (defaults to AUTO).

2023/05/11 追記

Homebrew にも 8.0.33 が落ちてきたようです。brew upgrade mysql-client しましょう。