Delete mysql database recorder

Hi, My recorder works on mysql but the history page is so so slow that i think the database is to big… My question is how can i find and delete my history database?

Thanks for helping!

Check the doc about service recorder.purge

Thank you, I didn’t read this. I’ve set it to 1 week. Is it true that the database is not cleaned up now? Is it still possible to get all the old data out?

If you don’t care about the data in your recorder database and just want to start fresh: shutdown HA, access your MySQL server either through command line or phpMyAdmin, drop the HA database, create a new empty database with the correct permissions, start HA. HA will then create the appropriate tables and start filling it with data according to your recorder configuration.

thanks for the info! Which database should I delete to do what you say? And maybe a crazy question but I can’t turn HA off and then get into PHPadmin, can I?

depends on how you installed HA. The steps I laid out are the safest way to delete the database to avoid potential corruption within HA. I also run HA Container so recorder database is in a separate docker container. i do not run HA OS or HA Supervised. You could probably just drop the database then reboot HA and it’ll work just fine. HA will only complain for a little bit because it can’t find the database until it is recreated.

In your case, the database you want to drop is “homeassistant”.

thanks man! i delete my “homeassistant” with PHP. and mt storage is from 96% to 31% haha now i set the service purge on. Do you have more tips :face_with_raised_eyebrow:

recorder:
purge_keep_days: 5
db_url: mysql://homeassistant:

this is what i have right now

The only other tip I have is follow the community guide on tuning your recorder. You can pick and choose (exclude and include) different entities and domains so only the stuff you want is saved in history. This combined with your purge keep days will keep the database at a manageable level and in some cases prevent premature wear out of an SD card. If you want to keep more data or keep it longer, you might want to look into hosting the database on a separate machine across the network with more storage.