前提・実現したいこと
https://www.youtube.com/watch?v=ltDdZAJli8c&t=3s コチラの動画を参考に、 docker-compose run web rails db:create
というコマンドを実行し、DBを作成しようとしたところ下記の様なエラーが発生してしまいます。
コチラを解決し、DBを作成したいです。
発生している問題・エラーメッセージ
Creating rails_docker_web_run ... done Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory Couldn't create 'app_production' database. Please check your configuration. rails aborted! ActiveRecord::ConnectionNotEstablished: Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory Caused by: Mysql2::Error::ConnectionError: Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory Tasks: TOP => db:create (See full trace by running task with --trace) ERROR: 1
該当のソースコード
docker-compose.yml
YAML
1version: '3' 2services: 3 db: 4 image: mysql:8.0 5 command: --default-authentication-plugin=mysql_native_password 6 volumes: 7 - ./src/db/mysql_data:/var/lib/mysql 8 environment: 9 MYSQL_ROOT_PASSWORD: password 10 web: 11 build: . 12 command: bundle exec rails s -p 3000 -b '0.0.0.0' 13 volumes: 14 - ./src:/app 15 ports: 16 - "3000:3000" 17 depends_on: 18 - db 19
YAML
1# MySQL. Versions 5.5.8 and up are supported. 2# 3# Install the MySQL driver 4# gem install mysql2 5# 6# Ensure the MySQL gem is defined in your Gemfile 7# gem 'mysql2' 8# 9# And be sure to use new-style password hashing: 10# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html 11# 12default: &default 13 adapter: mysql2 14 encoding: utf8mb4 15 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 16 username: root 17 password: password 18 host: db 19 20development: 21 <<: *default 22 database: app_development 23 24# Warning: The database defined as "test" will be erased and 25# re-generated from your development database when you run "rake". 26# Do not set this db to the same as development or production. 27test: 28 <<: *default 29 database: app_test 30 31# As with config/credentials.yml, you never want to store sensitive information, 32# like your database password, in your source code. If your source code is 33# ever seen by anyone, they now have access to your database. 34# 35# Instead, provide the password or a full connection URL as an environment 36# variable when you boot the app. For example: 37# 38# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" 39# 40# If the connection URL is provided in the special DATABASE_URL environment 41# variable, Rails will automatically merge its configuration values on top of 42# the values provided in this file. Alternatively, you can specify a connection 43# URL environment variable explicitly: 44# 45# production: 46# url: <%= ENV['MY_APP_DATABASE_URL'] %> 47# 48# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database 49# for a full overview on how database connection configuration can be specified. 50# 51production: 52 <<: *default 53 database: app_production 54 username: app 55 password: <%= ENV['APP_DATABASE_PASSWORD'] %>
試したこと
https://qiita.com/tomo-IR/items/224d33f14561e759dd16
↑野記事を参考にdocker内のmysqlにログインし、プラグインの状況を確認してみたのですが、
bash
1mysql> SELECT user, host, plugin FROM mysql.user; 2+------------------+-----------+-----------------------+ 3| user | host | plugin | 4+------------------+-----------+-----------------------+ 5| root | % | mysql_native_password | 6| mysql.infoschema | localhost | caching_sha2_password | 7| mysql.session | localhost | caching_sha2_password | 8| mysql.sys | localhost | caching_sha2_password | 9| root | localhost | mysql_native_password | 10+------------------+-----------+-----------------------+
rootユーザーのpluginは、mysql_native_password になっているため、どこが原因なのかわからなくなってしまいました。
補足情報(FW/ツールのバージョンなど)
mysql v8.0
ruby v2.7.2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/04/11 03:58