728x90
반응형
스프링부트에서 MySQL을 세팅하다가 에러가 발생했다.
1. 상황 설명
// build.gradle
runtimeOnly 'com.mysql:mysql-connector-j'
//application.yml
spring:
datasource:
url: jdbc:mysql://localhost:3306/database
username: username
password: password
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto=update:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
Gradle 세팅이나 데이터베이스 설정 정보는 문제가 없었는데 연결이 안되고 에러가 발생했다.
2. 해결방법
다른 곳의 문제가 아닌 연결을 시도한 mysql 계정의 권한 문제였다.
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP ON your_database.* TO 'new_user'@'localhost';
FLUSH PRIVILEGES;
[참고자료]
https://spring.io/guides/gs/accessing-data-mysql
Getting Started | Accessing data with MySQL
To package and run the application, we need to provide an external MySQL database rather than using Spring Boot Docker Compose Support. For this task, we can reuse the provided compose.yaml file with a few modifications: First, modify the ports entry in co
spring.io
728x90
'개발일지 > SPRING' 카테고리의 다른 글
[Spring Data JPA] @CreatedDate, @LastModifiedDate가 null이 들어가는 이유 (0) | 2024.06.20 |
---|---|
[Spring] Spring Boot 3.x에 Swagger 설정하기 (예시 코드) (0) | 2024.06.11 |
[Spring Boot] 스프링 부트 프로젝트 생성 (0) | 2023.11.27 |
[Spring] 스프링 빈 설정과 라이프 사이클 (1) | 2023.10.23 |
[Spring] IoC & Container (BeanFactory, ApplicationContext) 개념 (0) | 2023.10.22 |