I have Hassbian last version (from 2.7.2019). How I installed MySQL:
sudo apt install default-mysql-server
2. Create database
sudo mysql -u root
CREATE DATABASE hass_db; CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON hass_db.* TO 'username'@'localhost'; FLUSH PRIVILEGES; quit;
sudo service mysql restart
sudo apt-get install libmariadb-dev-compat libssl-dev sudo apt-get install default-libmysqlclient-dev libssl-dev pip3 install mysqlclient
sudo -u homeassistant -H -s source /srv/homeassistant/bin/activate pip3 install mysqlclient
Configuration recorder in yaml:
recorder: purge_keep_days: 1 db_url: mysql://username:password@localhost/hass_db?charset=utf8 include: entities: - sensor.livingroom_temperature - sensor.outdoors_temperature - sensor.boiler_temperature - sensor.wboiler_temperature - switch.boiler - switch.heating - switch.wboiler
The installation is successful. It works for several days, but after appears error: 2002, “Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)” home assistant. Saving to MySQL is broken.
Question: Is it installation correct? Can be a problem in purge_keep_days: 1, it can delete an important configuration?