This is from my home assistant notes on when I setup MySQL on my synology nas:
I’ve installed a docker mysql container instead of relying on Home Assistant’s built in. I pulled sameersbn/mysql via ssh and used the line below to initialise:
docker run --net=host --restart=always --name mysql -d -v /volume1/docker/mysql/data:/var/lib/mysql -e 'DB_USER=hass' -e 'DB_PASS=12345' -e 'DB_NAME=homeassistant' sameersbn/MySQL
Here’s what worked for me (hopefully, it can help others):
SSH into Synology NAS and pull the image using docker pull sameersbn/mysql:latest. After you login as admin, you may have to run sudo su if you keep getting permission errors.
Make sure that the folder /volume1/docker/mysql/data exists (or create one, if it does not).
Run, the command docker run --net=host --restart=always --name mysql -d -v /volume1/docker/mysql/data:/var/lib/mysql -e 'DB_USER=hass' -e 'DB_PASS=12345' -e 'DB_NAME=homeassistant' sameersbn/mysql:latest
Add the following to the config (where 192.168.2.113 is the IP address of my NAS):
I haven’t really been checking that file specifically but it is staying around 200mb which is a major improvement over the 3gb it used to be. And I’m definitely happy with the performance improvement.
Or you can exclude certain domains or sensors from being tracked. Do you need to keep track of time or date sensors? How about the sun sensor? Things like this add a LOT of useless data you’ll never track as well as the overhead penalties of poor performance.
That, plus moving to innodb_file_per_table helped enormously and both things were fairly easy to implement even with limited MySQL skills.
I got some alarms from unraid today and shows my log and db blowing up. I’ve added purge after 90 days to the config. I see that the db is storing the historal component, but how did the log file grow to be 12 gigs???
I don’t think that home-assistant log have a maximal size or conservation period.
They’ll grow forever.
My home-assistant run in a docker container, it’s easy to limit the log size if you’re running in a docker container by using:
However during installing (sudo apt-get install mysql-server && sudo apt-get install mysql-client) I get below. Any ideas? (there seems to be a relation to HAbridge but same result if I stop HABridge)
We know that using mysql instead of the sqllite improves performance. Has anyone used mysql, but put the database on a different host and observed the performance improvement over just having it on the same host?