在 1Panel 的应用商店中,Umami 镜像默认支持的数据库为 MySQL 和 PostgreSQL。但个人常用的数据库是 MariaDB,尽管理论上它应与 MySQL 完全兼容,但在实际安装过程中仍出现了报错。
问题一:数据库连接失败
首先是连接信息,如果在不做任何修改的情况下启动 Umami 容器,将会得到如下报错:
$ node scripts/check-db.js ✓ DATABASE_URL is defined. ✗ Unable to connect to the database: Authentication failed against database server, the provided database credentials for `umami` are not valid.
Please make sure to provide valid database credentials for the database server at the configured address.
A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
Migration name: 05_add_visit_id Database error code: 1305 Database error: FUNCTION umami.BIN_TO_UUID does not exist
Please check the query number 2 from the migration file.
这是由于 MariaDB 和 MySQL 的差异所导致的报错,BIN_TO_UUID 是 MySQL 8.0+ 内置的函数(用于将二进制数据转换为 UUID 字符串)。MariaDB (v11.8.3) 没有该函数,但我们可以手动创建。