LoginSignup
0
0

mysqldumpを「8.0.32」にアップグレードするとRDSのMySQL環境に対して、mysqldumpができなくなったときの対応メモ

Posted at

発生した事象について(2023/5月時点)

Amazon RDSのMySQL8環境に対して「mysqldump」コマンドを使用して、指定したスキーマのバックアップを取得しようとしたところ次のエラーが発生した。

$ mysqldump --defaults-extra-file=設定ファイル --single-transaction -R --set-gtid-purged=OFF --default-character-set=utf8 --hex-blob スキーマ名
 mysqldump: Couldn't execute 'FLUSH TABLES WITH READ LOCK': Access denied for user ユーザ名 (using password: YES) (1045)

原因

おそらくこれが原因:公式ドキュメント

The data and the GTIDs backed up by mysqldump were inconsistent when the options --single-transaction and --set-gtid-purged=ON were both used. It was because in between the transaction started by mysqldump and the fetching of , GTIDs on the server could have increased already. With this fixed, a FLUSH TABLES WITH READ LOCK is performed before the fetching of to ensure its value is consistent with the snapshot taken by mysqldump. GTID_EXECUTEDGTID_EXECUTED

↓以下翻訳↓

single-transaction と --set-gtid-purged=ON のオプションを両方使用すると、mysqldump でバックアップしたデータと GTID に矛盾が生じました。
これは、mysqldumpによって開始されたトランザクションと、サーバ上のGTIDのフェッチの間に、既に増加している可能性があるためです。
この修正により、FLUSH TABLES WITH READ LOCK がフェッチの前に実行され、その値が mysqldump によって取得されたスナップショットと一致することが確認されました。

つまり「8.0.32」のバージョンアップでFLUSH TABLES WITH READ LOCKを実行する際に権限が必要になったため、権限がないと怒られている。
じゃあ、権限付与してあげればいいじゃん。。というわけにもいかなかった↓

解決方法

  • 対処法1:実行ユーザーに権限を付与する方法(不採用)

    • Amazon RDS環境だとrootユーザでログインして実行ユーザに権限を付与することはできないため不採用(2023/5月現在)
  • 対処法2:mysql実行時に「--single-transaction 」オプションを外して実行する(不採用)

    • テーブルロックが外れるため一貫性が保てない可能性があるため不採用
  • 対処法3:mysqldumpのダウングレード(決定)

    • 上の対応方法ではダメそうなので暫定的に「8.0.31」にダウングレード

mysqldumpのダウングレード方法

ここから目的のバージョンの「MySQL Community Server」をダウンロードする

※私の環境ではUbuntuだったのでUbuntu20.04の場合の方法

$ wget -P https://downloads.mysql.com/archives/get/p/23/file/mysql-server_8.0.31-1ubuntu20.04_amd64.deb-bundle.tar
$ tar xf mysql-server_*bundle.tar

おそらく依存関係の問題でエラーが出るので、依存関係のあるパッケージをインストールする
※私の場合、以下が必要でした

  • mysql-common_8.0.31
  • mysql-community-client-plugins_8.0.31
  • mysql-community-client-core_8.0.31
  • mysql-client_8.0.31
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0