MySQL + Docker
2021/05/15
MySQL 初期化
- MySQL :: MySQL 8.0 リファレンスマニュアル :: 2.10.1 データディレクトリの初期化
- CentOS に MySQL8.0をインストールする | 404 motivation not found
bin/mysqld --initialize --user=mysql & とか /usr/sbin/mysqld --user=mysql --initialize & とか
5.7 からは mysqld --initialize に変更。それ以前は mysql_install_db 。
ディレクトリ初期化
# chown -R mysql /var/lib/mysql/
# chgrp -R mysql /var/lib/mysql/
※ basedir = /var/lib/mysql/ の場合
mysql-files
Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
初期管理者パスワード変更
Warning: Using a password on the command line interface can be insecure
シェルスクリプト
wait
コマンド実行結果を echo で出力
Docker の MySQL公式イメージ
それ以上のことを行いたい場合には別の方法で行う必要がある。 鍵をにぎるのが同じくdocker-entrypoint.shの中に記述のある、/docker-entrypoint-initdb.d/だ。 このディレクトリにある、シェルスクリプトやsqlファイルが実行されるようになっている。
何……だと……(早く知りたかった
Docker Compose
ログ確認には docker-compose logs 。