Skip to content

Admin container fails to connect to external MariaDB database #3449

Closed
@kswtch

Description

Environment & Version

  • Docker Compose version v2.12.0
  • Version: 2024.06

Description

After upgrading to the latest 2024.06 version the admin container is unable to connect to an external MariaDB database due to incompatible collation.

Replication Steps

  • Use MariaDB as an external database backend. In my case version 11.5.2.
  • Update mailu to the latest version.

Observed behaviour

The admin container failes with

sqlalchemy.exc.DatabaseError: (mysql.connector.errors.DatabaseError) 1273 (HY000): Unknown collation: 'utf8mb4_0900_ai_ci'

Expected behaviour

Admin container should be able to connect to either mysql or mariadb backends.

Cause

MariaDB has no support for utf8mb4_0900_ai_ci which is the new default since MySQL version 8.0. In the current sqlalchemy version shipped with mailu, the mysqlconnector sets utf8mb4_0900_ai_ci as the collation to use when connecting. This causes all MariaDB connections to fail.

Workaround

Overwrite the default collation for mysqlconnector in the connection string in mailu.env:

SQLALCHEMY_DATABASE_URI=mysql+mysqlconnector://<user>:<passwd>@<host>/<database>?collation=utf8mb4_unicode_ci

Possible Solution

Include the "mariadbconnector" module for sqlalchemy and use it in the sqlalchemy connection string. Currently it is not included with the version shipped by mailu.

Metadata

Assignees

No one assigned

    Labels

    type/bugBug. Not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions