[Spring Error] The server time zone value is unrecognized or represents more than one time zone 에러

2021. 2. 1. 16:41·Error code 모음/5. JAVA, Spring errors
반응형

Java spring 과 MySQL 서버를 연결하던 중 time zone 에러가 발생했고, 에러는 아래와 같았다. 

java.sql.SQLException: The server time zone value is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

 

1. 에러의 원인


에러의 원인은 서버 시간대의 값이 인식되지 않거나, 스프링(java) 와 MySQL 의 시간대가 다를 때 발생한다고 한다.

 

 


 

2. 해결 방법


1) 우선 MySQL 의 GLOBAL(전역) 및 SESSION time zone (시간대) 값을 확인한다. 아래의 명령어로 확인 가능하다

SELECT @@GLOBAL.time_zone, @@SESSION.time_zone;

아래와 같이 나타난다 

'SYSTEM'으로 설정이 되어 있다는 것은  MySQL 서버 시간대가 시스템 시간대와 동일한 것으로써 설정되어 있어서 mysql 서버 시간이 구체적으로 명시되어 있지 않는 것을 나타낸다.

 

이 때문에 Exception이 발생한 것이며, 지금 설명하는 방법으로 하면 되는것 같다. 그 외 몇가지 방법이 더 있지만, 이 방법이 나에게는 가장 쉽다고 판단되었기에 아래의 방법을 사용했다. 나머지 방법에 대해서는 아래 참고 링크로 걸어두고 추후 복습하거나 같은 에러가 발생했을 때 써먹어봐야 겠다.

 

 

 

 

2) SET statement 명령어 실행

 

이 방법을 통해 mysql 에 서버 시간을 설정할 수 있다. 시간대는 UTC 부터 오프셋을 나타내는 문자열로 지정이 가능하다고 한다. 가령 UTC 로 지정하려면 '+0:00' 으로 하면되며, KST 로 지정하려면 '+9:00' 으로 지정하면 된다.

SET GLOBAL time_zone = '+9:00';    # 권한 필요
SET time_zone = '+9:00';

성공하면 위와 같이 변한다.

 

** SET GLOBAL time_zone은 실행하려면 권한이 필요하며 이점 주의할 것(ROOT 권한) **

 


 

3. 참고 링크


atoz-develop.tistory.com/entry/MySQL-The-server-time-zone-value-is-unrecognized-or-represents-more-than-one-time-zone

 

[MySQL] The server time zone value is unrecognized or represents more than one time zone 에러 해결 방법

The server time zone value is unrecognized or represents more than one time zone 에러 해결 방법 Java에서 로컬 MySQL 서버에 연결하던 중 아래와 같은 에러가 발생했다. java.sql.SQLExcept..

atoz-develop.tistory.com

 

반응형
저작자표시 비영리 변경금지 (새창열림)

'Error code 모음 > 5. JAVA, Spring errors' 카테고리의 다른 글

[Spring Error] The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler  (0) 2021.03.07
[Spring Error] Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set  (0) 2021.02.13
[Spring Error] MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client [duplicate]  (0) 2021.02.01
[Spring Error] nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy  (0) 2021.02.01
[JAVA Error] The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path  (0) 2021.01.28
'Error code 모음/5. JAVA, Spring errors' 카테고리의 다른 글
  • [Spring Error] The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
  • [Spring Error] Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
  • [Spring Error] MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client [duplicate]
  • [Spring Error] nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
쟈누
쟈누
Ad astra per aspera
    반응형
  • 쟈누
    쟈누의 기록공간
    쟈누
  • 전체
    오늘
    어제
    • 분류 전체보기 (444)
      • AWS (31)
        • Glue (4)
        • S3 (1)
      • 클라우드 (0)
      • Data Engineering (37)
        • GitHub (10)
        • NiFi (11)
        • Spark (10)
        • Snowflake (0)
        • 머신러닝, AI (6)
      • 언어 (118)
        • 데이터 베이스 (42)
        • JAVA (9)
        • Python (34)
        • Java Script (15)
        • Linux (18)
      • 프로젝트, 인강 그리고 책 (30)
        • Spotify Project (7)
        • RASA chatbot Project (9)
        • Naver shopping Project (6)
        • 빅데이터를 지탱하는 기술 (8)
      • OLD (56)
        • IT 용어 사전 (13)
        • Front End (12)
        • Back End (31)
      • Error code 모음 (165)
        • 1. SQL errors (17)
        • 2. Hadoop errors (20)
        • 3. Linux Errors (14)
        • 4. Python errors (33)
        • 5. JAVA, Spring errors (41)
        • 6. Jav Script errors (10)
        • 7. Dev Tools errors (9)
        • 8. Git errors (8)
        • 9. Jenkins Errors (4)
        • 10. airflow Errors (2)
        • 11. Aws errors (7)
      • 개인 (1)
        • 책 (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
    • 블로그 관리
    • 글쓰기
  • 링크

  • 공지사항

    • 간단한 블로그 소개
  • 인기 글

  • 태그

    설치
    파이썬
    install
    node
    SQL
    리눅스
    MySQL
    NiFi
    java
    json
    Spring
    API
    Git
    error
    에러
    AWS
    Python
    python error
    자바
    linux
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
쟈누
[Spring Error] The server time zone value is unrecognized or represents more than one time zone 에러
상단으로

티스토리툴바