Skip to content

week3 tech

BOHYEON SEO edited this page Nov 22, 2019 · 2 revisions

MySQL-docker

μž‘μ„±μž : 김희선, μ„œλ³΄ν˜„

  1. dockerμ—μ„œ mysql이 μ‹€ν–‰λ˜λ„λ‘ ν•˜κΈ°
  • mysql은 ν•„μš”ν•œ νŒŒμΌλ“€μ€ 거의 μ—†μ—ˆκΈ° λ•Œλ¬Έμ—
    • root λΉ„λ°€λ²ˆν˜Έ μ„€μ •
    • μœ μ € μΆ”κ°€ 및 λΉ„λ°€λ²ˆν˜Έ μ„€μ •
    • 초기 데이터 μ‚½μž…
    • μœ μ €μ—κ²Œ λ°μ΄ν„°λ² μ΄μŠ€ κΆŒν•œ μ£ΌκΈ°

μœ„ λ„€κ°€μ§€λ§Œ ν•„μš” ν–ˆλ‹€.

  • ν™˜κ²½λ³€μˆ˜λ₯Ό λ„˜κ²¨μ£ΌλŠ” κ²ƒμœΌλ‘œ μ‰½κ²Œ ν•΄κ²°ν•  수 μžˆλ‹€.
environment: 
    MYSQL_ROOT_PASSWORD: p@ssword
    MYSQL_USER: dbblo
    MYSQL_PASSWORD: db1004
    MYSQL_DATABASE: sanctuary
- user, passwordλ₯Ό μ„€μ •ν•΄μ€€λ’€ databaseλ₯Ό λ§Œλ“€μ–΄μ£Όλ©΄ λ§Œλ“€μ–΄μ€€ μœ μ €λŠ” ν•΄λ‹Ή λ°μ΄ν„°λ² μ΄μŠ€μ— κΆŒν•œμ„ λΆ€μ—¬λ°›λŠ”λ‹€.
  1. 초기 데이터 μ‚½μž…
  1. ν•œκΈ€ν™”
  • cnfνŒŒμΌμ„ μž‘μ„±ν•œ λ’€ /etc/mysql/conf.d/λ””λ ‰ν† λ¦¬λ‘œ 이동
[client]
default-character-set = utf8

[mysqld]
init_connect = SET collation_connection = utf8_general_ci
init_connect = SET NAMES utf8
character-set-server = utf8
collation-server = utf8_general_ci
# μ•„λž˜ ν•œμ€„μ„ 넣지 μ•ŠμœΌλ‹ˆ ν•œκΈ€μ΄ κΉ¨μ§€λŠ” λ¬Έμ œκ°€ λ°œμƒν–ˆλ‹€.
skip-character-set-client-handshake

[mysqldump]
default-character-set = utf8

[mysql]
default-character-set = utf8
  • μœ„ cnfνŒŒμΌμ€ lucas의 MySQL μ„€μΉ˜ ν•­λͺ©μ—μ„œ 거의 κ·ΈλŒ€λ‘œ κ°€μ Έμ™”λ‹€.
  • skip-character-set-client-handshake ν•œμ€„λ§Œ λΉΌκ³ 
  • MySQL의 폰트 μ„€μ • 확인법
    • show variables like β€˜character%
    • mysql> status
  1. μ•”ν˜Έ μ•”ν˜Έν™”
  1. (λ―Έκ΅¬ν˜„) volumeμ‚¬μš©ν•΄μ„œ 지속적인 데이터 μœ μ§€
  • volume을 μ΄μš©ν•˜λ©΄ ncloud λ‘œμ»¬μ— MySQL의 데이터λ₯Ό μœ μ§€ν•˜λ„λ‘ ν•  수 μžˆλ‹€.
  • ν˜„μž¬λŠ” μΌλΆ€λŸ¬ ν•΄λ‹Ή κΈ°λŠ₯을 μ΄μš©ν•΄μ£Όμ§€ μ•Šκ³  있음
  • 배포 μ „λž΅ λ“± 변경이 있기 λ•Œλ¬Έμ— μ§€μ†μ μœΌλ‘œ μ΄ˆκΈ°ν™” ν•΄μ£Όκ³  μžˆλ‹€.
  • μΈν„°λ„·μ—μ„œ λ³Έ μ½”λ“œλ₯Ό κ·ΈλŒ€λ‘œ λ”°λΌμ„œ λ„£μœΌλ©΄ 될 것 κ°™μ§€λ§Œ, μ •ν™•ν•œ μ‚¬μš©λ²•μ„ μ•Œκ³ , directory μœ„μΉ˜ 등도 μ’€ 더 λͺ…ν™•νžˆ 지정해주고 μ‹Άλ‹€.

TroubleShooting

  1. Password λ―Έμ„€μ •μ‹œ mysql μžμ²΄κ°€ μ‹€ν–‰λ˜μ§€ μ•ŠμŒ
  • λžœλ€νŒ¨μŠ€μ›Œλ“œ, νŒ¨μŠ€μ›Œλ“œ 곡백 ν—ˆμš© λ“±μ˜ μ˜΅μ…˜μ΄λΌλ„ 해주지 μ•ŠμœΌλ©΄ μ‹€ν–‰λ˜μ§€ μ•ŠλŠ”λ‹€.
  1. docker μ‰˜μ— 접속 docker exec -it docker_db /bin/bash
  • -it μ˜΅μ…˜μ΄ μ€‘μš”ν•˜λ‹€.
  1. volumeμ‚¬μš© ν›„ 데이터가 μœ μ§€λΌμ„œ λΉ„λ°€λ²ˆν˜Έλ₯Ό 변경해도 μœ μ €λΉ„λ°€λ²ˆν˜Έκ°€ λ³€κ²½λ˜μ§€ μ•ŠλŠ” λ“±μ˜ 문제
  • docker-compose up -V
  • -V μ˜΅μ…˜μ„ ν•΄μ£Όλ©΄ λ³Όλ₯¨μ„ μ΄ˆκΈ°ν™” ν•œλ‹€.
Clone this wiki locally