Database/MySql

[MySQL] java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

hyeseo 2022. 9. 23. 22:45
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

 

❗️에러 발생 원인


useSSL=false로 설정하고 allowPublicKeyRetrieval 설정을 하지 않은 경우입니다.

 

 

☘️ 해결 방법


allowPublicKeyRetrieval=true

DB Source URL에 위 설정을 추가 했습니다.

 

 

application.properties.yml - 소스 수정

-- 수정전
spring.datasource.url=jdbc:mysql://localhost:3309/ex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&defaultFetchSize=1000&useSSL=false

-- 수정 후
spring.datasource.url=jdbc:mysql://localhost:3309/ex?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&defaultFetchSize=1000&useSSL=false&allowPublicKeyRetrieval=true