레알윙 2020. 7. 4. 13:09
반응형

예제

의존성 추가

<dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
</dependency>

 

 

docker 설치

https://www.docker.com/

 

 

아래 소스 실행

docker run -p 3306:3306 --name mysql_boot -e MYSQL_ROOT_PASSWORD=1 -e MYSQL_DATABASE=springboot -e MYSQL_USER=jinseok -e MYSQL_PASSWORD=pass -d mysql
docker exec -i -t mysql_boot bash
mysql -u root -p

소스 설치결과

 

 

 

 

MySQL용 Datasource 설정

spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useSSL=false
spring.datasource.username=jinseok
spring.datasource.password=pass

 

 

 

 

MySQL 접속시 에러MySQL 5.* 최신 버전 사용할 때

문제 Sat Jul 21 11:17:59 PDT 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
해결 jdbc:mysql:/localhost:3306/springboot?useSSL=false

MySQL 8.* 최신 버전 사용할 때

문제 com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
해결 jdbc:mysql:/localhost:3306/springboot?useSSL=false&allowPublicKeyRetrieval=true

MySQL 라이센스 (GPL) 주의

  • MySQL 대신 MariaDB 사용 검토
  • 소스 코드 공개 의무 여부 확인

 

 

반응형