<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://89sooner.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://89sooner.github.io/" rel="alternate" type="text/html" /><updated>2022-01-12T23:53:16+00:00</updated><id>https://89sooner.github.io/feed.xml</id><title type="html">89sooner’s Blog</title><subtitle>An amazing website.</subtitle><author><name>Kim Soon Ho</name></author><entry><title type="html">about docker-mysql</title><link href="https://89sooner.github.io/tools/docker-mysql/" rel="alternate" type="text/html" title="about docker-mysql" /><published>2022-01-13T12:52:00+00:00</published><updated>2022-01-13T12:52:00+00:00</updated><id>https://89sooner.github.io/tools/docker-mysql</id><content type="html" xml:base="https://89sooner.github.io/tools/docker-mysql/">&lt;p&gt;도커 설치
우분투 shell에 접속하여 도커를 설치한다.&lt;/p&gt;

&lt;h1 id=&quot;최신-버전으로-패키지-업데이트&quot;&gt;최신 버전으로 패키지 업데이트&lt;/h1&gt;
&lt;p&gt;sudo apt-get update&lt;/p&gt;

&lt;h1 id=&quot;도커-다운을-위해-필요한-패키지-설치&quot;&gt;도커 다운을 위해 필요한 패키지 설치&lt;/h1&gt;
&lt;p&gt;sudo apt-get install apt-transport-https // 패키지 관리자가 https를 통해 데이터 및 패키지에 접근할 수 있도록 해준다.
sudo apt-get install ca-certificates // certificate authority에서 발행되는 디지털 서명. SSL 인증서의 PEM 파일이 포함되어 있어 SSL 기반 앱이 SSL 연결이 되어있는지 확인할 수 있다.
sudo apt-get install curl // 특정 웹사이트에서 데이터를 다운로드 받을 때 사용한다.
sudo apt-get install software-properties-common // *PPA를 추가하거나 제거할 때 사용한다.&lt;/p&gt;

&lt;h1 id=&quot;curl-명령어로-도커의-공식-gpg-키를-추가&quot;&gt;curl 명령어로 도커의 공식 GPG 키를 추가&lt;/h1&gt;
&lt;p&gt;curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add&lt;/p&gt;

&lt;h1 id=&quot;도커의-공식-gpg-키가-추가된-것을-확인&quot;&gt;도커의 공식 GPG 키가 추가된 것을 확인&lt;/h1&gt;
&lt;p&gt;sudo apt-key fingerprint 0EBFCD88&lt;/p&gt;

&lt;h1 id=&quot;도커의-저장소를-추가-등록&quot;&gt;도커의 저장소를 추가, 등록&lt;/h1&gt;
&lt;p&gt;sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”&lt;/p&gt;

&lt;h1 id=&quot;최신-버전으로-패키지-업데이트-1&quot;&gt;최신 버전으로 패키지 업데이트&lt;/h1&gt;
&lt;p&gt;sudo apt-get update&lt;/p&gt;

&lt;h1 id=&quot;도커-설치&quot;&gt;도커 설치&lt;/h1&gt;
&lt;p&gt;sudo apt-get install -y docker-ce&lt;/p&gt;

&lt;h1 id=&quot;도커-실행해보기&quot;&gt;도커 실행해보기&lt;/h1&gt;
&lt;p&gt;sudo usermod -aG docker ubuntu&lt;/p&gt;

&lt;h1 id=&quot;도커-compose-설치&quot;&gt;도커 compose 설치&lt;/h1&gt;
&lt;p&gt;sudo curl -L “https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose&lt;/p&gt;

&lt;h1 id=&quot;권한-설정-해주기&quot;&gt;권한 설정 해주기&lt;/h1&gt;
&lt;p&gt;sudo chmod +x /usr/local/bin/docker-compose&lt;/p&gt;

&lt;h1 id=&quot;링크-파일-생성&quot;&gt;링크 파일 생성&lt;/h1&gt;
&lt;p&gt;sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose&lt;/p&gt;

&lt;p&gt;도커가 설치되었다면, docker-compose.yml을 이용하여 mysql을 설치해보겠다.&lt;/p&gt;

&lt;p&gt;docker라는 디렉토리를 만들어서 진행해보자&lt;/p&gt;

&lt;p&gt;mkdir docker
cd docker
vi docker-compose.yml
docker-compose.yml 파일에 아래와 같이 적어준다.&lt;/p&gt;

&lt;p&gt;version: ‘3’ # docker compose 버전 
services:
  local-db:
    image: library/mysql:5.7
    container_name: subway_local # 컨테이너 이름
    restart: always
    ports:
      - 13306:3306 # 로컬의 13306 포트를 컨테이너의 3306포트로 연결
    environment:
      MYSQL_USER: air
      MYSQL_PASSWORD: air
      MYSQL_ROOT_PASSWORD: root
      TZ: Asia/Seoul
    volumes:
      - ./db/mysql/data:/var/lib/mysql
      - ./db/mysql/init:/docker-entrypoint-initdb.d
아래의 명령어를 실행하면 도커 mysql이 설치된다.&lt;/p&gt;

&lt;p&gt;sudo docker-compose up -d
Mysql 설정
컨테이너에 접속해서 mysql 설정을 해보자.&lt;/p&gt;

&lt;p&gt;docker exec -it [컨테이너 이름] bash # 컨테이너에 접속.
mysql -u root -p # Mysql 접속 
root 유저를 사용하기 보단 다른 유저를 사용하는 것이 좋다. 우리는 아까 docker-compose.yml에 MYSQL_USER 값을 줬기 때문에 air라는 유저가 생성되있을 것이다.&lt;/p&gt;

&lt;p&gt;유저를 확인해보고 싶다면 아래의 명령어로 확인해 볼 수 있다.&lt;/p&gt;

&lt;p&gt;mysql&amp;gt; use mysql;
mysql&amp;gt; select user, host from user;&lt;/p&gt;

&lt;p&gt;참고로 host의 %는 모든 ip에서 접근할 수 있다는 뜻이다.&lt;/p&gt;

&lt;p&gt;air에게 모든 db 및 테이블에 접근 권한을 부여해주자.&lt;/p&gt;

&lt;p&gt;mysql&amp;gt; grant all privileges on &lt;em&gt;.&lt;/em&gt; to ‘air’@’%’; # 권한 부여
mysql&amp;gt; flush privileges; # 권한 적용
그리고 사용할 DB(spring boot의 applicaiton.yml 파일에 설정해 놓은 DB이름)를 생성해준다.(utf8 설정도 해줘야 한글과 관련 문제가 생기지 않는다.)&lt;/p&gt;

&lt;p&gt;mysql&amp;gt; CREATE DATABASE [db_name] DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
잘 돌아가면 성공! 👏👏👏&lt;/p&gt;

&lt;p&gt;MySQL 대소문자 관련 이슈
똑같이 따라 했는데 빈 생성 오류 같은 이상한 오류가 뜰 수 있다.&lt;/p&gt;

&lt;p&gt;이는 우분투 mysql의 대소문자 구분 기본 설정이 대소문자 구분함으로 되어있기 때문이다. schema.sql 쿼리문을 바꿔주던가 mysql 설정을 변경해줘야한다.&lt;/p&gt;

&lt;p&gt;mysql 설정을 변경해서 이 에러를 해결해보겠다.&lt;/p&gt;

&lt;p&gt;먼저 mysql 컨테이너에 접속한다.&lt;/p&gt;

&lt;p&gt;docker exec -it [컨테이너 이름] bash # 컨테이너에 접속.
그리고 아주 높은 확률로 docker 컨테이너에 vi가 설치되어있지 않을 것이다. 환경설정 파일을 수정해야하므로 vim을 설치해주자.&lt;/p&gt;

&lt;p&gt;root@[컨테이너id]:/# apt-get update
root@[컨테이너id]:/# apt-get install vim
이제 설정파일에 lower_case_table_names의 속성 값을 줘야한다. 기본 값은 0이다. 0이 대소문자를 구분한다는 뜻이고, 이 값을 1로 정해준다.&lt;/p&gt;

&lt;p&gt;root@[컨테이너id]:/# vi /etc/mysql/mysql.conf.d/mysqld.cnf //설정 파일 접속
lower_case_table_names = 1을 추가해주자.&lt;/p&gt;

&lt;p&gt;이렇게 해 준 다음, 이전 실행시 남아있는 쓰레기 값들이 있어서 이것까지 지워주자.&lt;/p&gt;

&lt;p&gt;root@[컨테이너id]:/# rm -rf /var/lib/mysql/[DB_NAME]
그 후 mysql 재시작 해주기!&lt;/p&gt;

&lt;p&gt;root@[컨테이너id]:/# service mysql restart&lt;/p&gt;</content><author><name>Kim Soon Ho</name></author><category term="Tools" /><summary type="html">도커 설치 우분투 shell에 접속하여 도커를 설치한다.</summary></entry><entry><title type="html">vue.js 시작을 위한 vscode, wsl2, docker 환경 설정</title><link href="https://89sooner.github.io/tools/thirds-post/" rel="alternate" type="text/html" title="vue.js 시작을 위한 vscode, wsl2, docker 환경 설정" /><published>2021-12-06T03:42:00+00:00</published><updated>2021-12-06T03:42:00+00:00</updated><id>https://89sooner.github.io/tools/thirds-post</id><content type="html" xml:base="https://89sooner.github.io/tools/thirds-post/">&lt;p&gt;vue.js 시작을 위한 vscode, wsl2, docker 환경 설정&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Linux용 Windows 하위 시스템에 Vue.js 설치
https://docs.microsoft.com/ko-kr/windows/dev-environment/javascript/vue-on-wsl&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;
        &lt;p&gt;vscode도 Linux용 Windows 하위 시스템 wsl2에 설치 
https://docs.microsoft.com/ko-kr/windows/dev-environment/javascript/windows-or-wsl&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Linux용 Windows 하위 시스템과 함께 Visual Studio Code 사용 시작하기
https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-vscode&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;WSL2에 vscode remote wsl 연동하기
https://velog.io/@gidskql6671/WSL-WSL2-%EC%84%A4%EC%B9%98-VSCode-%EC%97%B0%EB%8F%99&lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;연동할 때 remote error 발생시 Windows Powershell에서 wsl –shutdown&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;WSL 2에서 Docker 원격 컨테이너 시작하기(vscode wsl 연동하려면 필요)
https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;</content><author><name>Kim Soon Ho</name></author><category term="Tools" /><summary type="html">vue.js 시작을 위한 vscode, wsl2, docker 환경 설정</summary></entry><entry><title type="html">To study Ansible</title><link href="https://89sooner.github.io/tools/seconds-post/" rel="alternate" type="text/html" title="To study Ansible" /><published>2021-11-23T20:40:00+00:00</published><updated>2021-11-23T20:40:00+00:00</updated><id>https://89sooner.github.io/tools/seconds-post</id><content type="html" xml:base="https://89sooner.github.io/tools/seconds-post/">&lt;p&gt;To study Ansible&lt;/p&gt;</content><author><name>Kim Soon Ho</name></author><category term="Tools" /><summary type="html">To study Ansible</summary></entry><entry><title type="html">Welcome to Jekyll!</title><link href="https://89sooner.github.io/jekyll/update/first-post/" rel="alternate" type="text/html" title="Welcome to Jekyll!" /><published>2021-11-22T12:26:28+00:00</published><updated>2021-11-22T12:26:28+00:00</updated><id>https://89sooner.github.io/jekyll/update/first-post</id><content type="html" xml:base="https://89sooner.github.io/jekyll/update/first-post/">&lt;p&gt;You’ll find this post in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll serve&lt;/code&gt;, which launches a web server and auto-regenerates your site when a file is updated.&lt;/p&gt;

&lt;p&gt;To add new posts, simply add a file in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; directory that follows the convention &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YYYY-MM-DD-name-of-post.ext&lt;/code&gt; and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.&lt;/p&gt;

&lt;p&gt;Jekyll also offers powerful support for code snippets:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print_hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;print_hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Tom'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Check out the &lt;a href=&quot;https://jekyllrb.com/docs/home&quot;&gt;Jekyll docs&lt;/a&gt; for more info on how to get the most out of Jekyll. File all bugs/feature requests at &lt;a href=&quot;https://github.com/jekyll/jekyll&quot;&gt;Jekyll’s GitHub repo&lt;/a&gt;. If you have questions, you can ask them on &lt;a href=&quot;https://talk.jekyllrb.com/&quot;&gt;Jekyll Talk&lt;/a&gt;.&lt;/p&gt;</content><author><name>Kim Soon Ho</name></author><category term="jekyll" /><category term="update" /><summary type="html">You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.</summary></entry></feed>