MySQL + Docker

2021/05/15

MySQL 初期化

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でのMySQLのセットアップ方法とその仕組みを理解する

何……だと……(早く知りたかった

Docker Compose

ログ確認には docker-compose logs


Written by Circle
A mound built by the accumulation of hyperlinks are like Kowloon.