0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

docker-composeでMySQL環境を導入する

Last updated at Posted at 2023-01-01

概要

よくdocker-composeでmysqlを組み込むことがあるのでそれの覚書

設定ファイル

db_home下に
・DB用データ格納場所
・設定ファイルがある場合はconf.dフォルダ下に格納
・初期化スクリプトがある場合はsetup-ddlフォルダ下に格納
すればOK

docker-compose.yml
version: "3"
services:
  db:
    container_name: mysql
    image: mysql:8
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: database
      MYSQL_USER: user
      MYSQL_PASSWORD: password
      TZ: 'Asia/Tokyo'
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    volumes:
    - ./db_home/data:/var/lib/mysql
    - ./db_home/conf.d:/etc/mysql/conf.d
    - ./db_home/setup-ddl:/docker-entrypoint-initdb.d
    ports:
    - 3306:3306
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?