k8kjda
@k8kjda (UUU)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

Dockerでdbのみ起動できない

解決したいこと

Dockerの環境構築中、dbのみ起動せず困っています。
環境はmacOS 13.6.7、シェルはzshです。
ターミナルで$ docker-compose up -dまたは、デスクトップアプリのDocker Desktop.appから実行しても、一瞬起動してすぐにdbだけ落ちてしまいます。
解決方法を教えて下さい。

発生している問題・エラー

2024-07-05 18:16:49 240705  9:16:49 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2024-07-05 18:16:49 240705  9:16:49 [Note] mysqld (mysqld 5.5.62) starting as process 1 ...
2024-07-05 18:16:49 240705  9:16:49 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2024-07-05 18:16:49 240705  9:16:49 [Note] Plugin 'FEDERATED' is disabled.
2024-07-05 18:16:49 mysqld: Table 'mysql.plugin' doesn't exist
2024-07-05 18:16:49 240705  9:16:49 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2024-07-05 18:16:49 240705  9:16:49 InnoDB: The InnoDB memory heap is disabled
2024-07-05 18:16:49 240705  9:16:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-07-05 18:16:49 240705  9:16:49 InnoDB: Compressed tables use zlib 1.2.11
2024-07-05 18:16:49 240705  9:16:49 InnoDB: Using Linux native AIO
2024-07-05 18:16:49 240705  9:16:49 InnoDB: Initializing buffer pool, size = 128.0M
2024-07-05 18:16:49 240705  9:16:49 InnoDB: Completed initialization of buffer pool
2024-07-05 18:16:49 240705  9:16:49 InnoDB: highest supported file format is Barracuda.
2024-07-05 18:16:49 InnoDB: Log scan progressed past the checkpoint lsn 49439
2024-07-05 18:16:49 240705  9:16:49  InnoDB: Database was not shut down normally!
2024-07-05 18:16:49 InnoDB: Starting crash recovery.
2024-07-05 18:16:49 InnoDB: Reading tablespace information from the .ibd files...
2024-07-05 18:16:49 InnoDB: Restoring possible half-written data pages from the doublewrite
2024-07-05 18:16:49 InnoDB: buffer...
2024-07-05 18:16:49 InnoDB: Doing recovery: scanned up to log sequence number 1595675
2024-07-05 18:16:49 240705  9:16:49  InnoDB: Starting an apply batch of log records to the database...
2024-07-05 18:16:49 InnoDB: Progress in percents: 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2024-07-05 18:16:49 InnoDB: Apply batch completed
2024-07-05 18:16:49 240705  9:16:49  InnoDB: Waiting for the background threads to start
2024-07-05 18:16:50 240705  9:16:50 InnoDB: 5.5.62 started; log sequence number 1595675
2024-07-05 18:16:50 240705  9:16:50 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2024-07-05 18:16:50 240705  9:16:50 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
2024-07-05 18:16:50 240705  9:16:50 [Note] Server socket created on IP: '0.0.0.0'.
2024-07-05 18:16:50 240705  9:16:50 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
2024-07-05 18:16:57 240705  9:16:57 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2024-07-05 18:16:57 240705  9:16:57 [Note] mysqld (mysqld 5.5.62) starting as process 1 ...
2024-07-05 18:16:57 240705  9:16:57 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2024-07-05 18:16:57 240705  9:16:57 [Note] Plugin 'FEDERATED' is disabled.
2024-07-05 18:16:57 mysqld: Table 'mysql.plugin' doesn't exist
2024-07-05 18:16:57 240705  9:16:57 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2024-07-05 18:16:57 240705  9:16:57 InnoDB: The InnoDB memory heap is disabled
2024-07-05 18:16:57 240705  9:16:57 InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-07-05 18:16:57 240705  9:16:57 InnoDB: Compressed tables use zlib 1.2.11
2024-07-05 18:16:57 240705  9:16:57 InnoDB: Using Linux native AIO
2024-07-05 18:16:57 240705  9:16:57 InnoDB: Initializing buffer pool, size = 128.0M
2024-07-05 18:16:57 240705  9:16:57 InnoDB: Completed initialization of buffer pool
2024-07-05 18:16:57 240705  9:16:57 InnoDB: highest supported file format is Barracuda.
2024-07-05 18:16:57 InnoDB: Log scan progressed past the checkpoint lsn 49439
2024-07-05 18:16:57 240705  9:16:57  InnoDB: Database was not shut down normally!
2024-07-05 18:16:57 InnoDB: Starting crash recovery.
2024-07-05 18:16:57 InnoDB: Reading tablespace information from the .ibd files...
2024-07-05 18:16:57 InnoDB: Restoring possible half-written data pages from the doublewrite
2024-07-05 18:16:57 InnoDB: buffer...
2024-07-05 18:16:57 InnoDB: Doing recovery: scanned up to log sequence number 1595675
2024-07-05 18:16:57 240705  9:16:57  InnoDB: Starting an apply batch of log records to the database...
2024-07-05 18:16:57 InnoDB: Progress in percents: 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2024-07-05 18:16:57 InnoDB: Apply batch completed
2024-07-05 18:16:57 240705  9:16:57  InnoDB: Waiting for the background threads to start
2024-07-05 18:16:58 240705  9:16:58 InnoDB: 5.5.62 started; log sequence number 1595675
2024-07-05 18:16:58 240705  9:16:58 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
2024-07-05 18:16:58 240705  9:16:58 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
2024-07-05 18:16:58 240705  9:16:58 [Note] Server socket created on IP: '0.0.0.0'.
2024-07-05 18:16:58 240705  9:16:58 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

自分で試したこと

ログからエラー箇所をググッて片っ端からターミナルで実行していますが、ログのエラー内容自体変わらず解決に至っていません。

0

2Answer

2024-07-05 18:16:49 240705 9:16:49 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

2024-07-05 18:16:57 240705 9:16:57 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

2024-07-05 18:16:58 240705 9:16:58 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

mysql.pluginmysql.hostテーブルがオープンできないと言ってます。
mySQLを再インストールしたらどうでしょうか。

0Like

Comments

  1. @k8kjda

    Questioner

    hoge-db1をrmしてからdocker-compose up -d してみましたが、変わりませんでした。。

まずはdocker-compose.ymlと使っていたらDockerfileも記載しましょう

それを記載できたら、以下の疑念が多少は調査可能な状態になります。
docker hubにある公式mysqlイメージ

をベースにしている場合、確かデフォルトで/var/lib/mysqlをvolumeにしていたはずです。docker compose downしたあともそこにデータベースのデータが残っているのですが、そこが何か都合の悪い状態になっているとそのような状態になることが考えられます。

何にせよ、質問を最初に記載する際にその程度のことが分からないのに、dockerやmysqlを使うのはあまりオススメしません(何かあっても他人に聞かないと何もできないので)。

0Like

Comments

  1. @k8kjda

    Questioner

    そうですよね、、勉強します。。ありがとうございました。

Your answer might help someone💌