Home Assistant and MySQL - 2022.7 Breakage
Really? I mean... really?
If you’ve been running a Home Assistant container with a separate MySQL instance as the back-end for the recorder database (such as I am with my HA-on-Kubernetes setup), you will undoubtedly have noticed that it breaks horribly the moment you try to upgrade to 2022.7.
To sum up the issue (home-assistant/core #74539), someone made a mistake updating the Dockerfile for packaging Home Assistant, and left out a certain crucial library.
MySQLdb.OperationalError: (1045, 'Plugin caching_sha2_password could not be loaded: Error loading shared library /usr/lib/mariadb/plugin/caching_sha2_password.so: No such file or directory')Now, the issue in question has been closed, and the pull request (home-assistant/docker #247) to fix it - all one line of it - has been merged, but this has not yet showed up in any releases (to date, it’s not fixed in 2022.7.5 despite being broken in 2022.7.0), and there’s no word on when it might show up in some releases.
So how do we, the hapless users, fix it?
Well, there’s been a wide assortment of terrible advice going around on this point, like changing the password of the MySQL user to a different encryption scheme (despite caching_sha2_password being the latest, and the recommended, scheme to use), or patching a running Home Assistant container to add the library using docker exec (despite such a patch going away whenever the running container is recreated).
Don’t do either of those.
Create yourself a working directory, and then put this Dockerfile in it:
| FROM homeassistant/home-assistant:2022.7.5 | |
| RUN apk add --no-cache mariadb-connector-c |
Then build the image with:
docker build --push -t cerebrate/home-assistant:2022.7.5…obviously substituting your own Docker repository/user id for mine, there, and changing the version number in both the Dockerfile and command line appropriately.
Now you have a working image to run in place of homeassistant/home-assistant. This should keep you going with each release until they get around to publishing a version with the fix in it.

It has, however, been fixed now in 2022.8.