こんにちわ。以下の動画を見ながらDockerの開発環境を実装していたのですが
この動画の1:55:01の箇所で「 docker-compose run web rails db:create」を実行したのですが
以下のようなエラーが発生します。再起動したりデータベース名を確認したのですが誤りはありませんでした。
ログを見るとプラグインテーブルが開けないとありますがイマイチよくわかりません。どうしたらいいでしょう。
もし足りない情報があればご教示おねがいします
docker-compose.yml version: '3' services: db: image: mysql:8.0 command: --default-authentication-plugin=mysql_native_password volumes: - ./src/db/mysql_data:/var/lib/mysql environment: MYSQL_PASSWORD: password web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - ./src:/app ports: - "3000:3000" depends_on: - db
database.yml # MySQL. Versions 5.5.8 and up are supported. # # Install the MySQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: password host: db development: <<: *default database: app_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: app_test # As with config/credentials.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password or a full connection URL as an environment # variable when you boot the app. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # If the connection URL is provided in the special DATABASE_URL environment # variable, Rails will automatically merge its configuration values on top of # the values provided in this file. Alternatively, you can specify a connection # URL environment variable explicitly: # # production: # url: <%= ENV['MY_APP_DATABASE_URL'] %> # # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full overview on how database connection configuration can be specified. # production: <<: *default database: app_production username: app password: <%= ENV['APP_DATABASE_PASSWORD'] %>
エラー Unknown MySQL server host 'db' (-3) Couldn't create 'app_development' database. Please check your configuration. rails aborted! ActiveRecord::ConnectionNotEstablished: Unknown MySQL server host 'db' (-3) /app/bin/rails:5:in `<top (required)>' /app/bin/spring:10:in `block in <top (required)>' /app/bin/spring:7:in `tap' /app/bin/spring:7:in `<top (required)>' Caused by: Mysql2::Error::ConnectionError: Unknown MySQL server host 'db' (-3) /app/bin/rails:5:in `<top (required)>' /app/bin/spring:10:in `block in <top (required)>' /app/bin/spring:7:in `tap' /app/bin/spring:7:in `<top (required)>' Tasks: TOP => db:create (See full trace by running task with --trace)
ログ 2021-11-08T14:15:21.148352Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. 2021-11-08T14:15:21.148369Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as process 1 2021-11-08T14:15:21.163134Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive 2021-11-08T14:15:21.189751Z 0 [Warning] [MY-000054] [Server] World-writable config file '/var/lib/mysql/auto.cnf' is ignored. 2021-11-08T14:15:21.192301Z 0 [Warning] [MY-010107] [Server] World-writable config file '/var/lib/mysql/auto.cnf' has been removed. 2021-11-08T14:15:21.192990Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4ec113a1-409e-11ec-a254-0242ac130002. 2021-11-08T14:15:21.209684Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-11-08T14:15:21.701113Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. mysqld: Table 'mysql.plugin' doesn't exist 2021-11-08T14:15:21.795231Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure. 2021-11-08T14:15:21.795376Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 2021-11-08T14:15:21.795497Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 2021-11-08T14:15:21.795655Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 2021-11-08 14:15:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started. 2021-11-08 14:15:20+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2021-11-08 14:15:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started. 2021-11-08T14:15:21.795815Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 2021-11-08T14:15:21.795919Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 2021-11-08T14:15:21.796025Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 2021-11-08T14:15:21.796149Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 2021-11-08T14:15:21.822573Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2021-11-08T14:15:21.895318Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2021-11-08T14:15:21.901401Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main 2021-11-08T14:15:21.901427Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main 2021-11-08T14:15:21.901668Z 0 [Warning] [MY-013595] [Server] Failed to initialize TLS for channel: mysql_main. See below for the description of exact issue. 2021-11-08T14:15:21.901693Z 0 [Warning] [MY-010069] [Server] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 2021-11-08T14:15:21.903864Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. 2021-11-08T14:15:21.905031Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. 2021-11-08T14:15:21.907863Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. 2021-11-08T14:15:21.908061Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 2021-11-08T14:15:21.908183Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist 2021-11-08T14:15:21.908211Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition. 2021-11-08T14:15:21.908488Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 2021-11-08T14:15:21.908535Z 0 [ERROR] [MY-010952] [Server] The privilege system failed to initialize correctly. For complete instructions on how to upgrade MySQL to a new version please see the 'Upgrading MySQL' section from the MySQL manual. 2021-11-08T14:15:21.908810Z 0 [ERROR] [MY-010119] [Server] Aborting 2021-11-08T14:15:23.395379Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27) MySQL Community Server - GPL.
Dockerfile FROM ruby:2.7 RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ && apt-get update -qq \ && apt-get install -y nodejs yarn WORKDIR /app COPY ./src /app RUN bundle config --local set path 'vendor/bundle' \ && bundle install
[+] Running 1/1 ⠿ Container docker5-db-1 Recreated 2.7s [+] Running 1/1 ⠿ Container docker5-db-1 Started 1.2s => Booting Puma => Rails 6.1.4.1 application starting in production => Run `bin/rails server --help` for more startup options Puma starting in single mode... * Puma version: 5.5.2 (ruby 2.7.4-p191) ("Zawgyi") * Min threads: 5 * Max threads: 5 * Environment: production * PID: 1 * Listening on http://0.0.0.0:3000 Use Ctrl-C to stop