MariaDB schema uses char(0) columns on HAOS despite correct mysqlclient setup
The problem
The problem
On Home Assistant OS (HAOS) with the official MariaDB add-on, Home Assistant creates a broken schema with char(0) fields such as entity_id, last_updated, and attributes.
This suggests that Home Assistant is falling back to pymysql instead of using mysqlclient, even though HAOS includes mysqlclient by default and I'm using a mysql:// connection string (not pymysql://).
(ChatGPT wrote this. I personally have no idea. )
What version of Home Assistant Core has the issue?
core-2025.4.4
What was the last working version of Home Assistant Core?
Unknown â this is a new MariaDB installation.
What type of installation are you running?
Home Assistant OS
Integration causing the issue
recorder
Link to integration documentation on our website
No response
Diagnostics information
core_mariadb_2025-05-05T11-54-26.559Z.log
Example YAML snippet
### Example configuration.yaml
recorder:
db_url: mysql://homeassistant:password@core-mariadb/homeassistant?charset=utf8mb4
purge_keep_days: 35
auto_purge: true
Anything in the logs that might be useful for us?
After stopping Home Assistant, dropping the homeassistant database, recreating it, and restarting HA, the following schema is created:
CREATE TABLE `states` (
`state_id` bigint(20) NOT NULL AUTO_INCREMENT,
`entity_id` char(0) DEFAULT NULL,
`state` varchar(255) DEFAULT NULL,
`attributes` char(0) DEFAULT NULL,
`event_id` smallint(6) DEFAULT NULL,
`last_changed` char(0) DEFAULT NULL,
`last_updated` char(0) DEFAULT NULL,
...
);
Note that multiple fields are char(0), making queries fail (e.g., MIN(last_updated) returns null).
Additional information
I installed the MariaDB add-on via the Add-on Store This was a clean install The homeassistant database is created with charset utf8mb4 and collation utf8mb4_unicode_ci This issue occurs even after dropping and recreating the database
Suggested next steps Ensure mysqlclient is properly detected and used in HAOS Add a diagnostic warning if schema is being created with char(0) fields Confirm that pymysql is not being silently used on HAOS