DockerのMySQLが起動しない問題、exFATのせいだった の変更点
#author("2025-03-10T22:25:57+09:00","default:pitablog","pitablog")
* DockerのMySQLが起動しない問題、exFATのせいだった [#ccf875b3]
#splitbody{{
LEFT:
&tag(情報技術,Docker,MySQL);
#split
RIGHT:&size(13){投稿日: 2025-03-10 (月)};
}}
#bcontents
** はじめに [#c624155a]
Docker上でphp上のLaravelを扱うためにMySQLをdocker-composeを使って設定したのだが、バインドマウントを使うとエラーが出てMySQLが起動しない。もしくは起動しようとしてもすぐに落ちる。
最初からずばり言うと原因は「exFATではシンボリックリンクを利用できない」という。
#ika_twitter(tweet,PitaQ_Modding,1899026664220459101)
*** エラーログ [#qc3cf043]
#pre{{
>docker logs db
2025-03-10 12:40:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.2.0-1.el9 started.
2025-03-10 12:40:09+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-03-10 12:40:09+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.2.0-1.el9 started.
ln: failed to create symbolic link '/var/lib/mysql/mysql.sock': Operation not permitted
2025-03-10T12:40:10.236715Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2025-03-10T12:40:10.434941Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 9.2.0) starting as process 1
2025-03-10T12:40:10.440016Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2025-03-10T12:40:10.464379Z 0 [Warning] [MY-000054] [Server] World-writable config file '/var/lib/mysql/auto.cnf' is ignored.
2025-03-10T12:40:10.465303Z 0 [Warning] [MY-010107] [Server] World-writable config file '/var/lib/mysql/auto.cnf' has been removed.
2025-03-10T12:40:10.465840Z 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: ce08c379-fdac-11ef-8983-0242ac120005.
2025-03-10T12:40:10.528599Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-03-10T12:40:14.210872Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-03-10T12:40:17.666898Z 0 [Warning] [MY-013595] [Server] Failed to initialize TLS for channel: mysql_main. See below for the description of exact issue.
2025-03-10T12:40:17.666952Z 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
mysqld: Cannot change permissions of the file 'private_key.pem.temp' (OS errno 1 - Operation not permitted)
2025-03-10T12:40:17.824490Z 0 [ERROR] [MY-010295] [Server] Could not set file permission for private_key.pem
2025-03-10T12:40:17.824537Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-03-10T12:40:19.634094Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 9.2.0) MySQL Community Server - GPL.
2025-03-10T12:40:19.634130Z 0 [System] [MY-015016] [Server] MySQL Server - end.
2025-03-10 12:41:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.2.0-1.el9 started.
2025-03-10 12:41:28+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-03-10 12:41:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.2.0-1.el9 started.
ln: failed to create symbolic link '/var/lib/mysql/mysql.sock': Operation not permitted
2025-03-10T12:41:28.391010Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2025-03-10T12:41:28.589944Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 9.2.0) starting as process 1
2025-03-10T12:41:28.594564Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2025-03-10T12:41:28.632213Z 0 [Warning] [MY-000054] [Server] World-writable config file '/var/lib/mysql/auto.cnf' is ignored.
2025-03-10T12:41:28.633086Z 0 [Warning] [MY-010107] [Server] World-writable config file '/var/lib/mysql/auto.cnf' has been removed.
2025-03-10T12:41:28.633652Z 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: xxx.
2025-03-10T12:41:28.695202Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-03-10T12:41:32.222708Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-03-10T12:41:35.619653Z 0 [Warning] [MY-013595] [Server] Failed to initialize TLS for channel: mysql_main. See below for the description of exact issue.
2025-03-10T12:41:35.619699Z 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
mysqld: Cannot change permissions of the file 'private_key.pem.temp' (OS errno 1 - Operation not permitted)
2025-03-10T12:41:35.834933Z 0 [ERROR] [MY-010295] [Server] Could not set file permission for private_key.pem
2025-03-10T12:41:35.834972Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-03-10T12:41:37.636223Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 9.2.0) MySQL Community Server - GPL.
2025-03-10T12:41:37.636265Z 0 [System] [MY-015016] [Server] MySQL Server - end.
}}
ホスト(Windows)とコンテナ(WSLのLinux)との権限の差異により、バインドマウントしている先のフォルダに書き込むも同期できないよう。
で、そのMySQLはシンボリックリンクを使っているそう
つまり、NTFSなどのシンボリックリンクをサポートしているファイルシステムを用いるとこれは解決できそうだ。
** 対処法.1 [#q12e41b6]
先ほど述べたようにNTFSなどのシンボリックリンクをサポートしているファイルシステムにバインドマウントする場所を変更するとよさそうだ。
私はexFATのHDDからNTFSのHDDにバインドマウント先を含め、docker-compose.ymlの入っているフォルダを移動させた。
** 対処法.2 [#k325ded6]
my.cnfもしくはmy.confで以下の設定を追記すると起動できると思われる
[mysqld]
skip-symbolic-links
これにより、MySQLがシンボリックリンクをしないようにして対処する。
** コメント [#e1eae827]
#pctrlcmt
&size(10){キーワード: 情報技術, Docker, コンテナ, MySQL, データベース, エラー, バグ, シンボリックリンク, ファイルシステム, NTFS, exFAT, FAT32, docker-compose};