Homeassistant at docker - problem with recorder mysql

Hi.
My hass runnig without problems with mysql recorder until I went to the docker
Now my hass spits mistakes :

ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (_mysql_exceptions.OperationalError) (2002, 'Can\'t connect to local MySQL server through socket \'/var/run/mysqld/mysqld.sock\' (2 "No such file or directory")') (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)

My configuration docker-compose

version: ‘3’
services:
homeassistant:
container_name: home-assistant
image: homeassistant/home-assistant
volumes:
- /home/ihome/homeassistant/config:/config
- /etc/localtime:/etc/localtime:ro
restart: always
network_mode: host

How to enable hass to see mysql ?

How do you have mysql configured inside Home Assistant?

mysql is an operating system service available on loclahost.
mysql is not in the docker container

Except inside docker, you cannot refer to it as ‘localhost’. If your config says ‘localhost’, it will not work.

You need to specify the IP address of the host or you will need to get deep into some Docker networking.

It’s better now

2018-09-25 15:15:09 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (_mysql_exceptions.OperationalError) (2003, ‘Can't connect to MySQL server on '192.168.1.82' (111 “Connection refused”)’) (Background on this error at: Error Messages — SQLAlchemy 2.0 Documentation) (retrying in 3 seconds)

but not yet

you need to give the appropriate permissions:

grant all privileges on hass.* to hass@‘%’ identified by ‘xxxx’;
flush privileges;

and comment on my.cnf line :

#bind-address = 127.0.0.1

And it works :slight_smile:

thank you so much for help