폴더 구조
mysql/
Dockerfile
my.cnf
sqls/
initialize.sql
- Dockerfile
FROM mysql:8.0 ADD ./my.cnf /etc/mysql/conf.d/my.cnf
- my.cnf
utf8mb4는 이모지를 지원하는 utf8[mysqld] character-set-server=utf8mb4 [mysql] default-character-set=utf8mb4 [client] default-character-set=utf8mb4
데이터베이스 초기 설정
# mysql 컨테이너 접속
docker exec -it 컨테이너 아이디 /bin/bash
# .sql 파일 실행
cd docker-entrypoint-initdb.d/
mysql -u root -p --port 3306 < initialize.sql
MySQL 주의사항
cryptography package is required for sha256_password or caching_sha2_password auth methods 에러 해결하기
flask로 구축한 API를 호출할 때 cryptography 패키지 오류가 나타났다. 이 오류를 해결하는 간단한 방법에 대해 알아보자.
blog.harampark.com
aiomysql를 통해 async 연결을 하면, 에러가 발생하지만 해결되지 않는다.
pymysql 또는 mysql+connector를 통해 sync 연결을 하면 괜찮다.
성능이 pymysql이 훨씬 좋다는데 지금도 그러는지 확인이 필요하다.
'인프라' 카테고리의 다른 글
Git, release 브랜치 관리하기 (0) | 2024.05.16 |
---|---|
Github Action & 도커 허브에 이미지 전송 (1) | 2024.05.01 |
클라우드 개발 서버와 동일한 설정의 운영 서버 구축 (0) | 2024.03.10 |