LoginSignup
3
0

More than 5 years have passed since last update.

Werckerで「Mysql2::Error: Authentication plugin 'caching_sha2_password' cannot be loaded」が発生した際の対処について

Last updated at Posted at 2018-05-07

Werclerのプロセスが失敗

連休明けのとある日、いつものようにgit pushすると、CIに使っているWerckerからエラー通知が届いた。
内容を見てみるとspecにたどり着く以前の、テスト用DBを作成するステップでエラーになっていた。

エラーメッセージは「Mysql2::Error: Authentication plugin 'caching_sha2_password' cannot be loaded」。

Mysql2::Error: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory

~()~

/pipeline/cache/bundle-install/ruby/2.3.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate:reset => db:drop => db:check_protected_environments
(See full trace by running task with --trace)

Mysql2::Error: Authentication plugin 'caching_sha2_password' cannot be loaded

エラーメッセージでぐぐってみると、1つのブログに行き着いた。

MySQL 8.0.4におけるデフォルト認証形式の変更

MySQL8.0.4からはデフォルトの認証方式が"caching_sha2_password"に変わったとのこと。
サーバー側とクライアント側でそれぞれこの認証方式をサポートしていない場合、このエラーが発生するらしい。
このブログではmy.cnfにて"default_authentication_plugin"を設定することでこの問題を解決する
方法が説明されている。

MySQLイメージが更新されていた

DockerのMySQLのレポジトリを見てみると、2日前に更新されたと記載されていた。
最新バージョンは8.0.11。
おそらくこのアップデートでMySQLのデフォルトバージョンが8になったことで、このエラーが発生するようになったのではなかろうか。

wercker.ymlの設定を変更

CIにつかうMySQLのバージョンを以前の5系に指定してやればこの問題を回避できそう。
ということで、werckerの設定を変更。
tagでバージョン情報を明示したことで解決。

services:
  - id: mysql
    tag: 5.6 #これを追加
    env:
      MYSQL_USER: testuser
      ...
3
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
3
0