Post

2021-01-28-TIL

2021-01-28-TIL

1
docker --version
1
docker pull mysql/mysql-server:5.7
1
docker images
1
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password --name mysql-5.7 -v /Users/ham/db_data:/var/lib/mysql mysql/mysql-server:5.7
1
 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

Boxer 에뮬레이터

페르시아 왕자 개발일지 - iphone ebook 살아서 움직임

도커로 감싸서 보내면 실행되는걸 보냈다는 증거이기 때문에, 운영자 탓을 할 수 있다.

https://www.notion.so/1-be8b604a57d34a9bbf0f7e321ce51d5c

Docker internals

https://medium.com/@BeNitinAgarwal/understanding-the-docker-internals-7ccb052ce9fe

https://blog.naver.com/PostView.nhn?blogId=complusblog&logNo=220980996544&proxyReferer=https:%2F%2Fwww.google.com%2F

JUnit

https://dae-hwa.github.io/blog/2021-01-05–junit-%EC%84%A4%EC%A0%95%ED%95%B4%EB%B3%B4%EA%B8%B0/

How to install MySQL in Docker ★★★

  • https://hub.docker.com/r/mysql/mysql-server/
  • https://hub.docker.com/_/mysql
  • https://docs.docker.com/get-started/
  • http://jmlim.github.io/docker/2019/07/30/docker-mysql-setup/
  • https://docs.docker.com/get-started/
  • https://kjwsx23.tistory.com/383
  • https://github.com/ghojeong/gonggam-blog
1
docker exec -it mysql-5.7 /bin/bash

Change character set to UTF-8 Unicode

  • https://beanbroker.github.io/2019/07/07/docekr_encode/
  • https://kjwsx23.tistory.com/383

DB 설치하기

  • 가상 환경을 위해서 docker를 설치한다.
  • docker 기반으로 mysql server 5.7 버전을 설치한다.
  • docker 명령으로 mysql 컨테이너를 실행한다.
  • docker 명령으로 mysql 컨테이너에 bash로 접속한다.
  • 셀 환경변수와 locale 설정을 하고, mysql config를 latin1에서 utf8로 변경한다.
  • SQL 문법을 학습하고 DDL(Data Definition Language)과 DQL(Data Query Language) 예제를 연습한다.
  • docker 기반으로 mysql을 설치했는지 여부를 확인할 수 있도록 터미널 또는 GUI로 접속한 화면 캡처하고 gist에 함께 저장한다.

DB 요구사항

  • Database 이름을 정하고 Database를 생성한다.
  • DB에 프로그램에서 연결할 User를 정하고 생성한다. 접속 권한을 설정한다.

DB naming

  • https://launchbylunch.com/posts/2014/Feb/16/sql-naming-conventions/
1
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password --name mysql-5.7 -v /Users/ham/db_data:/var/lib/mysql mysql/mysql-server:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
1
docker exec -it mysql-5.7 mysql -uroot -p
ALTER DATABASE PCbang CHARACTER SET utf8 COLLATE utf8mb4_general_ci;
CREATE DATABASE PCbang default CHARACTER SET UTF8; 
SHOW DATABASES;
GRANT ALL PRIVILEGES ON PCbang.* TO august@localhost IDENTIFIED BY 'password'; 
EXIT; 
docker exec -it mysql-5.7 -u august -p
USE PCbang;
CREATE TABLE user_log (
    id INT PRIMARY KEY AUTO_INCREMENT, 
    name VARCHAR(32) NOT NULL, 
   	nickname VARCHAR(64) NOT NULL,
    money DECIMAL(10, 2),
    last_visit DATETIME, 
    phone VARCHAR(12) 
) ENGINE=INNODB;
  • ENGINE=INNODB 뜻 : https://www.quora.com/What-does-the-code-Engine-InnoDB-mean-in-MySql-when-creating-a-fact-table
INSERT INTO user_log (name, nickname, money, last_visit, phone) VALUES('Jacob', 'August', 10080.23, '2021-01-28', '01112345678');
  • SQL reference : https://futurists.tistory.com/11

실제로는 물리적으로 하나씩 있는 하드웨어 자원이 OS를 통해서 가상화되어 마치 여러개 있는것처럼 사용할 수 있게된다.

https://www.notion.so/2-5e20e5f9da0d45a593e3096ca37de56e

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ sudo -i #root
$ cat /etc/mysql/my.cnf
$ cat << 'EOF' > /etc/my.cnf
# for utf8 characterset
[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

[mysqldump]
default-character-set = utf8

[mysql]
default-character-set = utf8
EOF

How to create a console progress bar in Java?

https://kodejava.org/how-do-i-create-a-console-progress-bar/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class ConsoleProgressBar {
    public static void main(String[] args) {
        char[] animationChars = new char[]{'|', '/', '-', '\\'};

        for (int i = 0; i <= 100; i++) {
            System.out.print("Processing: " + i + "% " + animationChars[i % 4] + "\r");

            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        System.out.println("Processing: Done!          ");
    }
}

Docker references

  • https://github.com/ghojeong/gonggam-blog
1
2
3
4
5
6
7
docker stop $(docker ps -a -q) ;
docker rm $(docker ps -a -q) ;
docker rmi $(docker images -q) --force ;
docker system prune;
docker system prune --volumes;

kill -kill `lsof -t -i tcp:3000`

Monolithic Architecture

  • Monolithic

  • https://www.youtube.com/watch?v=BnS6343GTkY

Docker vs HyperVisor

Benefits of using Docker

  • https://www.44bits.io/ko/post/why-should-i-use-docker-container

  • https://www.microfocus.com/documentation/enterprise-developer/ed40pu5/ETS-help/GUID-F5BDACC7-6F0E-4EBB-9F62-E0046D8CCF1B.html

Virtualization

No hard PC bang : https://m.blog.naver.com/kkikseven1/221848377883

Linux version check command

  • https://sarc.io/index.php/forum/tips/535-linux-centos-ubuntu-os

  • https://ongal.tistory.com/190

Q) 도커를 stop하고 이미지 삭제 후 다시 설치했는데, mysql에 이전에 생성한 DB가 그대로 있습니다. 어째서 남아있는건지 모르겠습니다.

How to get a date one month ago

  • https://stackoverflow.com/questions/16392892/how-to-reduce-one-month-from-current-date-and-stored-in-date-variable-using-java

  • https://m.blog.naver.com/PostView.nhn?blogId=ljpark6&logNo=221352124661&proxyReferer=https:%2F%2Fwww.google.com%2F

Calendar DATE vs DAY_OF_MONTH

  • https://stackoverflow.com/questions/52068844/whats-the-difference-from-calendar-date-and-calendar-day-of-month

Generate Random String in Java

  • https://needneo.tistory.com/23

cheet sheet 만 모아놓은 사이트?

This post is licensed under CC BY 4.0 by the author.