본문 바로가기

프로젝트/개인

1. mysql 환경세팅하기

https://dev.mysql.com/downloads/windows/installer/5.7.html

 

버전 5.7

관리자: root cos1234

add user: cos cos1234

database name: blog

 

 

root, 1234로 접속

drop user cos;

-- 유저이름@아이피주소
create user 'cos'@'%' identified by 'cos1234';

-- ON DB이름.테이블명
-- TO 유저이름@아이피주소
GRANT ALL PRIVILEGES ON *.* TO 'cos'@'%';
CREATE DATABASE blog CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
use blog;

 

ini파일 C:\ProgramData\MySQL\MySQL Server 5.7 => 보기에서 숨김파일 보기 체크 필수

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
init_connect='SET collation_connection = utf8_general_ci'
character-set-server=utf8

수정 후 저장하고, ctrl alt delete 해서 mysql5.7 재시작

아래 명령어로 한글 적용됬는지 확인.

show variables like 'c%';

한글세팅 완료

pom.xml에 jpa와 mysql 디펜던시 주석처리 해제후 

application.yml에 

server:
  port: 8090
  servlet:
    context-path: /blog
    encoding:
      charset: UTF-8
      enabled: true
      force: true

spring:
  mvc:
    view:
      prefix: /WEB-INF/views/
      suffix: .jsp

  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/blog?serverTimezone=Asia/Seoul
    username: cos
    password: cos1234

  jpa:
    open-in-view: true
    hibernate:
      ddl-auto: create
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
      use-new-id-generator-mappings: false
    show-sql: true
    properties:
      hibernate.format_sql: true

  jackson:
    serialization:
      fail-on-empty-beans: false

context-path가 blog라고 되있으므로 

테스트해보려면

http://localhost:8090/blog/test/hello

이렇게 주소 입력.

use blog;
select * from user;
select * from board;
select * from reply;

실행 후 jpa테스트