0

I am trying to setup a keycloak server from docker compose file(not docker file) and connecting a database on my localhost. So I used host.docker.internal as my DB_ADDR param

version: '3.8'
services:
    keycloak:
        container_name: keycloak
        image: jboss/keycloak:15.0.2
        command:
          [
            '-b',
            '0.0.0.0',
            '-Dkeycloak.migration.action=import',
            '-Dkeycloak.migration.provider=dir',
            '-Dkeycloak.migration.dir=/opt/jboss/keycloak/realm-config',
            '-Dkeycloak.migration.strategy=OVERWRITE_EXISTING',
            '-Djboss.socket.binding.port-offset=1000',
            '-Dkeycloak.profile.feature.upload_scripts=enabled',
          ]
        volumes:
          - ./realm-config:/opt/jboss/keycloak/realm-config
        environment:
          - KEYCLOAK_USER=admin
          - KEYCLOAK_PASSWORD=xxxxxxx
      - DB_VENDOR=mysql
      - DB_USER=xxxxxxx
      - DB_PASSWORD=xxxxxxxxxx
      - DB_DATABASE=xxxxxx
      - DB_ADDR=host.docker.internal

and now I get error says:

com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '̫ƽ���׼ʱ��' is unrecognized or represents more than one time zone. Y
ou must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specific time zone value if you want to utilize time zone support.

It looks like a mysql timezone issue to me, but I have no idea where to put server timezone config in keycloak server in docker compose file

Daniel Hua
  • 153
  • 2
  • 8
  • 1
    Please read: [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question) --- This looks like an encoding problem. Are you running mysql on a windows host? – Turing85 Dec 02 '21 at 22:23
  • Have you tried to `configure either the server or JDBC driver (via the 'serverTimezone' configuration property)`? – Joundill Dec 03 '21 at 00:58
  • Does this answer your question? [The server time zone value 'AEST' is unrecognized or represents more than one time zone](https://stackoverflow.com/questions/37719818/the-server-time-zone-value-aest-is-unrecognized-or-represents-more-than-one-ti) – Joundill Dec 03 '21 at 01:00
  • @Turing85, yes I am running mysql on windows – Daniel Hua Dec 03 '21 at 01:41
  • @Joundill, not really, in the post, it mentioned the config param passing to jdbc, but as it is keycloak docker compose file, I do not know where to place the param. – Daniel Hua Dec 03 '21 at 01:42
  • @Joundill, if possible, I do not want to change the mysql version as some of my other dev dbs requires 8+ version of mysql. – Daniel Hua Dec 03 '21 at 01:45
  • @Turing85, thank you, I have edited my question to avoid nonsense question – Daniel Hua Dec 03 '21 at 01:47
  • Make surre your DB is in the UTF-8 encoding (or in the worst case use connection property `characterEncoding`in the JDBC settings, so Keycloak will know correct encoding of DB) – Jan Garaj Dec 04 '21 at 08:11

0 Answers0