Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-3873

Failure to initialize database with MySQL using UTF8

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.3.0.Final
    • Fix Version/s: 2.5.0.CR1
    • Component/s: Database
    • Labels:
      None
    • Environment:

      Mariadb 10.1, Keycloak 2.3.0 official docker image.

    • Steps to Reproduce:
      Hide

      Use this docker-compose setup:

      version: '2'
      services:
        mysql:
          image: mariadb:10.1
          expose:
            - "3306"
          environment:
            MYSQL_ROOT_PASSWORD: openidctest
            MYSQL_DATABASE: keycloak
            MYSQL_USER: keycloak
            MYSQL_PASSWORD: keycloak
          command:
            - --character-set-server=utf8mb4
            - --collation-server=utf8mb4_unicode_ci
        keycloak:
          image: jboss/keycloak-mysql:2.3.0.Final
          links:
            - mysql
          environment:
            KEYCLOAK_USER: admin
            KEYCLOAK_PASSWORD: openidctest
            MYSQL_DATABASE: keycloak
            MYSQL_USER: keycloak
            MYSQL_PASSWORD: keycloak
            # Workaround for container using legacy Docker links, resulting in
            # "WFLYCTL0211: Cannot resolve expression 'jdbc:mysql://${env.MYSQL_PORT_3306_TCP_ADDR}:${env.MYSQL_PORT_3306_TCP_PORT}
            MYSQL_PORT_3306_TCP_ADDR: mysql
            MYSQL_PORT_3306_TCP_PORT: "3306"
      

      Show
      Use this docker-compose setup: version: '2' services: mysql: image: mariadb: 10.1 expose: - "3306" environment: MYSQL_ROOT_PASSWORD: openidctest MYSQL_DATABASE: keycloak MYSQL_USER: keycloak MYSQL_PASSWORD: keycloak command: - --character-set-server=utf8mb4 - --collation-server=utf8mb4_unicode_ci keycloak: image: jboss/keycloak-mysql: 2.3 . 0 .Final links: - mysql environment: KEYCLOAK_USER: admin KEYCLOAK_PASSWORD: openidctest MYSQL_DATABASE: keycloak MYSQL_USER: keycloak MYSQL_PASSWORD: keycloak # Workaround for container using legacy Docker links, resulting in # "WFLYCTL0211: Cannot resolve expression 'jdbc:mysql: //${env.MYSQL_PORT_3306_TCP_ADDR}:${env.MYSQL_PORT_3306_TCP_PORT} MYSQL_PORT_3306_TCP_ADDR: mysql MYSQL_PORT_3306_TCP_PORT: "3306"

      Description

      With a MySQL database using UTF8, Keycloak initialization will fail with error "Specified key was too long; max key length is 767 bytes" (see attached log for details).

      A workaround is to create the keycloak database with latin1 charset. If you do want UTF8 however, resources I found on this error in other applications recommend choosing a different key.

      I tried --innodb-large-prefix=1 but it didn't help.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  hmlnarik Hynek Mlnařík
                  Reporter:
                  solsson Staffan Olsson
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: