뚜sh뚜sh

SpringBoot와 MySQL 연결 본문

MySQL

SpringBoot와 MySQL 연결

뚜sh뚜sh 2024. 1. 16. 18:10

1. MySQL 서버 연결 후 접속(접속은 안해도 됨)

 

2. Sequel Pro를 실행해서 커넥션을 연결한 후 Add Database로 원하는 이름의 데이터베이스 생성

 

3. start.spring.io로 프로젝트를 생성할 때 dependencies에 MySQL Driver 추가

build.gradle 파일

dependencies {
	runtimeOnly 'com.mysql:mysql-connector-j'
}

 

4. application.properties에 아래 코드 추가

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/[생성한 데이터베이스 이름]?serverTimezone=UTC&characterEncoding=UTF-8
spring.datasource.username=[name]
spring.datasource.password=[password]

'MySQL' 카테고리의 다른 글

VARCHAR과 LONGTEXT의 차이점과 사용법  (0) 2024.03.18
[ERROR] Sequel Pro "Loading database 'zz'"  (0) 2024.01.17
MySQL password 변경  (0) 2024.01.17
MySQL GUI 툴 - Sequal Pro 설치 및 실행  (0) 2024.01.16
[MacOS] MySQL 설치(Homebrew)  (0) 2024.01.16
Comments