Home Assistant cannot connect with Mariadb

Currently, I’m using Hassio on NUC (docker - Debain) and trying to integrate with Mariadb (not installed on docker) - Hassio docker and Mariadb run on the same NUC - Debian OS, but I cannot integrate them.

I followed this instruciton on youtube (https://www.youtube.com/watch?v=4rsxnN8gkHk)

Below is my config and the error in Hassio

recorder: 
   db_url: mysql://HA:[email protected]/HAdb?charset=utf8
   purge_keep_days: 365

Error


Hassio logs:

Error during connection setup: (MySQLdb._exceptions.OperationalError) (2002, "Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)")
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)

Anyone has experienced about this issue, can you help to advice me for this issue?
btw, I found in the error log of Hassio "Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ the folder dir is different with in Mariadb. I dont know whether it caused the connection issue or not.

anyone can help me on this issue? :frowning:

Try actual ip address of the NUC instead of localhost in your configuration.

mariadb works for me, however I’m using it outside docker, hopfully someone who is good with docker will help you here. :slight_smile:

I’m using Hassio docker and connect it with Mariadb outside. I dont install Mariadb in docker.

I tried the IP also. It cannot fix the issue :frowning:

Can other programs such as Grafana or PHPMyAdmin connect the DB?

I can connect other program with Mariadb but Hassio

Probably a docker issue then

I’m having this issue and it’s driving me insane!! Using the official MariaDb Hassio add-on. It connects just fine initially now that I changed to IP instead of local host, but it fails whenever it tries to query the recorder.

I also couldn’t get it to switch back to the MySQL default, so I’m stuck without any historical data in the frontend, and it’s turning into a problem.

Having the same issue after updating the MariaDB addon to the latest 2.0. And that’s the only thing that has changed.

Restoring a backup from before the MariaDB addon. Hope that works.

For me, upgrading Mariadb addon to v. 2.0 cleared the port 3306 used by the container; however, after manual re-input, it works again.

I had to change the recorder settings in the yaml from the IP I was using to core-mariadb.
Frenck helped me :slight_smile: