docker-compose.yml
version: '3'
services:
# MySQL
db:
image: mysql:5.7
platform: linux/amd64
container_name: mysql_host
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test_database
MYSQL_USER: docker
MYSQL_PASSWORD: docker
TZ: 'Asia/Tokyo'
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
- ./docker/db/data:/var/lib/mysql
- ./docker/db/my.cnf:/etc/mysql/conf.d/my.cnf
- ./docker/db/sql:/docker-entrypoint-initdb.d
ports:
- 3306:3306
以下コマンドを実行
docker-compose up -d
以下コマンドでroot
ユーザとしてアクセス可能
docker exec -it mysql_host /bin/bash
mysql --host=localhost --user=root --password=root