実現したいこと
laravelの開発をこれからしていくために勉強を始めたレベルの者です。
OSはwindowsPCなのでwsl2上で開発環境を構築しています。
laravelの環境構築にdockerを用いてmysqlを利用したいのですが、mysqlのコンテナのみうまく実行できず難航しています。
発生している問題・分からないこと
docker compose にて mysqlイメージをビルドした際、コンテナ起動後すぐにmysqlコンテナのみ
エラーが発生し、exit(1)という状態に抜けてしまいます。
問題の根本が理解できておらず途方にくれています。
勉強不足ですいませんが、解決に必要な知識等をご教授いただければ幸いです。
エラーメッセージ
error
1下記がdocker上でmysqlコンテナを起動させた際のログです 22024-06-10T06:33:47.044854Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 32024-06-10 15:33:47 mysqld: Table 'mysql.plugin' doesn't exist 42024-06-10 15:33:47 2024-06-10T06:33:47.153023Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure. 52024-06-10 15:33:47 2024-06-10T06:33:47.153489Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 62024-06-10 15:33:47 2024-06-10T06:33:47.153821Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 72024-06-10 15:33:47 2024-06-10T06:33:47.154129Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 82024-06-10 15:33:47 2024-06-10T06:33:47.154445Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 92024-06-10 15:33:47 2024-06-10T06:33:47.154823Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 102024-06-10 15:33:47 2024-06-10T06:33:47.155147Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 112024-06-10 15:33:47 2024-06-10T06:33:47.155415Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 122024-06-10 15:33:47 2024-06-10T06:33:47.187600Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 132024-06-10 15:33:47 2024-06-10T06:33:47.257847Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 142024-06-10 15:33:47 2024-06-10T06:33:47.263405Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main 152024-06-10 15:33:47 2024-06-10T06:33:47.263561Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main 162024-06-10 15:33:47 2024-06-10T06:33:47.264005Z 0 [Warning] [MY-013595] [Server] Failed to initialize TLS for channel: mysql_main. See below for the description of exact issue. 172024-06-10 15:33:47 2024-06-10T06:33:47.264164Z 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 182024-06-10 15:33:47 2024-06-10T06:33:47.267006Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. 192024-06-10 15:33:47 2024-06-10T06:33:47.268582Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. 202024-06-10 15:33:47 2024-06-10T06:33:47.271174Z 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. 212024-06-10 15:33:47 2024-06-10T06:33:47.271684Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables 222024-06-10 15:33:47 2024-06-10T06:33:47.272005Z 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 232024-06-10 15:33:47 2024-06-10T06:33:47.272202Z 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. 242024-06-10 15:33:47 2024-06-10T06:33:47.272812Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 252024-06-10 15:33:47 2024-06-10T06:33:47.273048Z 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. 262024-06-10 15:33:47 2024-06-10T06:33:47.273536Z 0 [ERROR] [MY-010119] [Server] Aborting 272024-06-10 15:33:48 2024-06-10T06:33:48.744176Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.26) MySQL Community Server - GPL.
該当のソースコード
docker
1services: 2 nginx: 3 image: nginx:1.21.1 4 ports: 5 - "80:80" 6 volumes: 7 - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf 8 - ./src:/var/www/ 9 depends_on: 10 - php 11 12 php: 13 build: ./docker/php 14 volumes: 15 - ./src:/var/www/ 16 17 mysql: 18 image: mysql:8.0.26 19 environment: 20 MYSQL_ROOT_PASSWORD: root 21 MYSQL_DATABASE: laravel_db 22 MYSQL_USER: laravel_user 23 MYSQL_PASSWORD: laravel_pass 24 command: 25 mysqld --default-authentication-plugin=mysql_native_password 26 volumes: 27 - ./docker/mysql/data:/var/lib/mysql 28 - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf 29 phpmyadmin: 30 image: phpmyadmin/phpmyadmin 31 environment: 32 - PMA_ARBITRARY=1 33 - PMA_HOST=mysql 34 - PMA_USER=laravel_user 35 - PMA_PASSWORD=laravel_pass 36 depends_on: 37 - mysql 38 ports: 39 - 8080:80
Dockerfile
1FROM php:7.4.9-fpm 2 3COPY php.ini /usr/local/etc/php/ 4 5RUN apt update \ 6 && apt install -y default-mysql-client zlib1g-dev libzip-dev unzip \ 7 && docker-php-ext-install pdo_mysql zip 8 9RUN curl -sS https://getcomposer.org/installer | php \ 10 && mv composer.phar /usr/local/bin/composer \ 11 && composer self-update 12 13WORKDIR /var/www
my.cnf
1[mysqld] 2character-set-server = utf8mb4 3 4collation-server = utf8mb4_unicode_ci 5 6default-time-zone = 'Asia/Tokyo'
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
ホストとコンテナの権限をrootで合わせているので、ファイルが開けないので権限問題で実行できていないのかと思いmy.cnfのパーミッションを読み取り専用などにもしましたが根本的な原因をわかっていないので解決にはつながっていません。
また、データベースの初期化に問題があるのかと思いクリーンアップしてみましたが何も変化は起きませんでした。
そもそもの原因が何か理解できていないのでご教授いただいきたいです。
補足
特になし
回答1件
あなたの回答
tips
プレビュー