Home [MySQL] M1에서 MySQL Docker 실행
Post
Cancel

[MySQL] M1에서 MySQL Docker 실행

Docker

1
2
3
4
docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
no matching manifest for linux/arm64/v8 in the manifest list entries
  • M1 진짜 빡
1
docker pull --platform linux/x86_64 mysql
1
2
3
4
5
6
7
8
docker run --platform linux/x86_64 
-p 3306:3306 
--name mysql-container
-e MYSQL_ROOT_PASSWORD=<root_passwd>
-e MYSQL_DATABASE=<dbname>
-e MYSQL_USER=<username>
-e MYSQL_PASSWORD=<passwd>
-d mysql

Docker Compose

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
version: '3'
services:
  mysql:
    image: library/mysql:5.7
    container_name: mysql-container
    restart: always
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: play
      TZ: Asia/Seoul
    volumes:
      - ./db/mysql/data:/var/lib/mysql
      - ./db/mysql/init:/docker-entrypoint-initdb.d
      - ./db/mysql/mycustom.cnf:/etc/mysql/conf.d/custom.cnf
    platform: linux/x86_64
    command:
        - --character-set-server=utf8
        - --collation-server=utf8_unicode_ci
1
2
3
4
# 실행
docker-compose up -d
# 종료 
docker-compose down

로그 확인

1
2
docker-compose logs -f
docker-compose logs -f <mysql>

실행된 도커 컨테이너에 접속

1
docker exec -it mysql-container bash

MySQL 접속

1
mysql -u root -p <passwd>
This post is licensed under CC BY 4.0 by the author.

[Git] Passwd가 아닌 Token 방식으로 변경

[MySQL] 초기 작업