No database or database user is created during this setup and will need to be created manually.
Consequently I followed these steps:
$ sudo mysql -u root -p
$ CREATE DATABASE homeassistant;
$ CREATE USER ‘homeassistantuser’ IDENTIFIED BY ‘password’;
$ GRANT ALL PRIVILEGES ON homeassistant.* TO ‘homeassistantuser’;
$ FLUSH PRIVILEGES; $ exit
And added following information in my configuration.yaml
Log into mysql client (you’ll be prompted for password, I made one up):
sudo mysql -u root -p
Configure mysql database as per @digieurope’s instructions:
MariaDB [(none)]> CREATE DATABASE homeassistant;
MariaDB [(none)]> CREATE USER ‘<some_user>’ IDENTIFIED BY ‘<some_password>’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON homeassistant.* TO ‘<some_user>’;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit
Restart home assistant
Worked like a charm for me!
WARNING: I wrote out these steps from memory, and YMMV!! So be careful and back up anything you’re worried about losing.
thank you. I’ve installed it, created user as homeassistantuser. with this
db_url: mysql://homeassistantuser:password@localhost/homeassistant in config,
but getting this error
2018-01-17 16:50:41 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: No module named ‘MySQLdb’ (retrying in 3 seconds)
in the localhost space do i put the rpi ip address?
Hi I’m trying to read the monthly consumption sensor on my POW sonoff with tasmota. I installed MariaDB add-on in HASSIO.
When I reboot, I can not see the sensor. Could you help me?
I attach the script and the sensor configuration
Thank’s!
name: Average Energy Consumption
query: >
SELECT ROUND(AVG(avg_per_day),2) ‘value’
FROM (
SELECT AVG(state) AS avg_per_day
FROM homeassistant.states
WHERE entity_id = ‘sensor.energy_yesterday’
AND state != ‘unknown’
AND state != ‘’
AND created > NOW() - INTERVAL 1 MONTH
homeassistant (created)
) avgs;
column: ‘value’
unit_of_measurement: kWh