본문 바로가기
C++ 200제/코딩 IT 정보

MySql SSL 설정 끄기, JDBC 연결 오류 해결 useSSL=false

by vicddory 2019. 3. 6.

MySql SSL 설정 끄기, JDBC 연결 오류 해결 useSSL=false


MySql이 5.5 버전부터 였나? SSL 접속을 기본으로 세팅해 놓았습니다. 그래서 SSL 처리를 안 하면 아래 같이 긴~ 에러 메시지를 보여줍니다. 경우에 따라선 경고로 그칠 수도 있으나, 어쨌든 MySql 기본값은 SSL 사용값이 true 이므로 꼭 짚고 넘어가야 합니다.


연결 오류 해결하지 않으면 빌드 / 실행할 때마다 아래 메시지를 보게 됩니다.


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.

핵심은 위에 파란색 글씨입니다. 에러 또는 경고 메시지 안에 답이 나와 있습니다.


가령 아래와 같이 접속 url string 변수를 설정하셨다면, 그 아래처럼 바꾸시면 됩니다.




▷ 연결 오류

1
String url = "jdbc:mysql://localhost:3306/jdbc?user=root&password=1234";
cs


▷ 연결 오류 해결 (정상)

1
String url = "jdbc:mysql://localhost:3306/jdbc?useSSL=false&user=root&password=1234";
cs



MySql SSL 설정 끄기, JDBC 연결 오류 해결 useSSL=false



자바 Properties 클래스를 사용한다면 아래처럼 소스를 구성할 수 있습니다.


1
2
3
4
5
6
7
8
9
10
11
12
Properties properties = new Properties();
properties.setProperty("user""root");
properties.setProperty("password""milos23");
properties.setProperty("useSSL""false");
properties.setProperty("autoReconnect""true");
 
try (Connection conn = 
        DriverManager.getConnection(connectionUrl, properties)) {
    ...
catch (SQLException e) {
    ...
}
cs


뭐, 다양하게 구성할 수 있는데 MySql에 적용하는 솔루션에 따라 소스 코드는 다를 수 있습니다. 연결 오류 메시지는 같습니다.


핵심은 useSSL 값을 false 로 바꿔 에러/경고 메시지를 지울 수 있다는 것이죠. 다만, SSL 설정을 하셨다면, 위 과정은 필요하지 않습니다.



관련 글


C# MySql 설치 사용법, connector 참조 추가와 데이터 읽기 예제


[R프로그래밍 기초 강좌] MySQL 연동하기, RMYSQL


HTML 구글맵. C# + 안드로이드 = 실시간 마커 갱신 (+MySql)




ⓒ written by vicddory

MySql SSL 설정 끄기, JDBC 연결 오류 해결 useSSL=false

댓글