본문 바로가기
웹개발/SpringBoot

MySQL 설치 및 Spring 연동 방법

by 철없는민물장어 2023. 6. 9.
728x90

https://downloads.mysql.com/archives/installer/

 

MySQL :: Download MySQL Installer (Archived Versions)

Please note that these are old versions. New releases will have recent bug fixes and features! To download the latest release of MySQL Installer, please visit MySQL Downloads. MySQL open source software is provided under the GPL License.

downloads.mysql.com

 

위 링크에서 mySQL 8.0.32버전을 다운받습니다.

설치과정에서 다른 설정은 건들지 않았습니다.

(설치 중간에 root 비밀번호는 설정해야 합니다)

 

설치가 완료되면 Workbench를 실행합니다.

 

동그라미 친 버튼을 클릭하여 스키마를 생성합니다. Name은 test로 설정하였습니다.

이후 아래에 있는 apply버튼을 눌러 적용합니다.

 

이후, 상단바에서 Server-Users and Privileges를 클릭합니다

좌측하단의 Add Account를 누르고, name을 설정해줍니다. 

 

 

Administrative Roles 탭을 클릭하여 모든 권한을 체크하고 적용합니다.

 

이후, Schema Privileges 탭을 클릭합니다

우측 Add Entry...버튼을 클릭합니다

 

Selected schema에서 아까 생성해뒀던 test스키마를 선택하고 ok합니다.

아래의 모든 권한을 체크하고 적용합니다.

 

여기까지 마쳤다면, 다시 워크벤치 홈으로 이동합니다.

+버튼을 눌러 커넥션을 생성합니다.

커넥션 네임과 유저네임을 각각 test로 설정하였습니다.

 

이제 application.yml을 확인합니다.

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/{schema name}?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&useSSL=true
    username: {username}
    password: {userpassword}

위와 같이 설정되어 있으면 됩니다.

 

본 포스팅에서는 스키마 네임, 유저네임을 test로 설정했고, 패스워드는 비워두었으므로 다음과 같이 적혀있으면 됩니다.

 

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&useSSL=true
    username: test
    password:
728x90

댓글