MariaDB Add-On Trouble

For some reason, I cannot get the MariaDB to work for me. Here is what I have in my config file:

recorder:
  purge_interval: 2
  purge_keep_days: 7
  db_url: mysql://hass:my-password@core-mariadb/homeassistant

And here is what I have in the MariaDB Options:

{
  "databases": [
    "homeassistant"
  ],
  "logins": [
    {
      "username": "hass",
      "host": "homeassistant",
      "password": "my-password"
    }
  ],
  "rights": [
    {
      "username": "hass",
      "host": "homeassistant",
      "database": "homeassistant",
      "grant": "ALL PRIVILEGES ON"
    }
  ]
}

Here is the logs from MariaDB:

starting version 3.2.2
[INFO] Use exists mariadb initial system
[INFO] Start MariaDB
180103 17:02:52 mysqld_safe Logging to '/data/databases/core-mariadb.err'.
180103 17:02:52 mysqld_safe Starting mysqld daemon with databases from /data/databases
[INFO] Init custom database
[INFO] Create database homeassistant
[INFO] Init/Update users
[INFO] Update user hass
[INFO] Init/Update rights
[INFO] Alter rights for hass@homeassistant - homeassistant

And yet I get this error every time x10.

2018-01-03 17:07:43 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (_mysql_exceptions.OperationalError) (2005, "Unknown MySQL server host 'core-mariadb' (-3)") (retrying in 3 seconds)

I’ve tried uninstalling it and reinstalling it. I’ve tried all sorts of options for the database, and I’ve even tried deleting my old history data to see if that would help. I’ve got nothing. Any help would be greatly appreciated.

Hi,
do you use the pi-hole addon? And is your DHCP DNS server your pi-hole IP?

If yes, read my posts here

No I do not use the pi-hole add on. I have Check Home Assistant configuration, Let’s Encrypt, Duckdns, Samba share, Rpc shutdown, Configurator, and Ssh server. Along with the Mariadb of course.

If MariaDB is running on the same host as HomeAssistant, try replacing mysql://hass:my-password@core-mariadb/homeassistant with mysql://hass:[email protected]/homeassistant or mysql://hass:my-password@localhost/homeassistant

edit: just realized this is for Hass.io, so my suggestions may not apply.

1 Like

My config looks like this

{
  "databases": [
    "homeassistant"
  ],
  "logins": [
    {
      "username": "hass",
      "host": "%",
      "password": "xxxx"
    }
  ],
  "rights": [
    {
      "username": "hass",
      "host": "%",
      "database": "homeassistant",
      "grant": "ALL PRIVILEGES ON"
    }
  ]
}


recorder:
  purge_interval: 1
  purge_keep_days: 15
  db_url: mysql://hass:xxx@core-mariadb/homeassistant
2 Likes

Same problem here, tried different settings for host in the mariadb config but nothing helped…

Thanks… changing host from core-mariadb to % fixed it for me :slight_smile:

1 Like

I am trying to get my home assistant to use MariaDB using the docker image however none of my history seems to be updating. I don’t seem to have any errors in the log file but they aren’t updating in history or the logbook either. If I stop my MariaDB docker then I do get a bunch of errors. Any ideas on what is going on or what to check for here? A lot of my devices show as unknown in the history or device history not found.

Thanks cgarwood - worked for me! Love 127.0.0.1-assistant

Hey, thanks! Changing host to % as you suggested worked for me as well.

Yesterday I’ve switched to ‘MariaDB’, installed from Add-on.
During configuration check I have error:

Configuration invalid
Component error: db_url - Integration 'db_url' not found.

The MariaDB log is showing that all is O.K.:

[12:06:36] INFO: Using existing mariadb initial system
[12:06:36] INFO: Starting MariaDB
191020 12:06:39 mysqld_safe Logging to '/data/databases/core-mariadb.local.hass.io.err'.
191020 12:06:39 mysqld_safe Starting mysqld daemon with databases from /data/databases
[12:06:45] INFO: Check data integrity and fix corruptions
[12:06:53] INFO: Init custom database
[12:07:02] INFO: Create database homeassistant
[12:07:02] INFO: Init/Update users
[12:07:08] INFO: Update user hass
[12:07:08] INFO: Init/Update rights
[12:07:11] INFO: Alter rights for hass@% - homeassistant

Configuration is following:

{
  "databases": [
    "homeassistant"
  ],
  "logins": [
    {
      "username": "hass",
      "host": "%",
      "password": "1234"
    }
  ],
  "rights": [
    {
      "username": "hass",
      "host": "%",
      "database": "homeassistant",
      "grant": "ALL PRIVILEGES ON"
    }
  ]
}

I’m not sure what is the meaning of the error ‘Component error: db_url - Integration ‘db_url’ not found.’
Where to look…?

P.S. ‘yaml’ configuration:

recorder:
db_url: mysql://hass:[email protected]/homeassistant?charset=utf8
1 Like

Strange - I’ve added only to the configuration ‘history:’ entry.
And the problem disapeared…
Now this part has entry:

# Set-up MariaDB for Hass.io
recorder:
   db_url: mysql://hass:[email protected]/homeassistant?charset=utf8

# Track history, changes, etc.
history:

Is that really needed ‘history:’ entry in ‘configuration.yaml’ when switched to ‘MariaDB’…???
I could not find "a must’ i any documentation/community. As per detailed documentation here:

The history integration will track everything that is going on within Home Assistant and allows the user to browse through it

The funny is that it is written, that:

This integration ‘history:’ is by default enabled, unless you’ve disabled or removed the default_config: line from your configuration.
Looks like this entry it is still needed in ‘configuration.yaml’…

It probably had to do with the indentation. You missed a TAB on db_url… In your next post you fixed that issue. I don’t think it has anything to do with the history tracker.

When I execed mariadb addon docker manually
I saw those database files, tables were created successfully.
So I solved it by doing following:

  1. clean up mariadb database files:
    rm -rf /usr/share/hassio/addons/data/core_mariadb/databases/*
  2. exec mariadb addon docker manually:
    docker run -it -v /usr/share/hassio/addons/data/core_mariadb/databases:/mnt homeassistant/armv7-addon-mariadb:ver /bin/sh
  3. watch the log output and press enter to get a shell inside the container when the log looks good.
  4. copy all files in /data/databases to /mnt
  5. quit container and restart mariadb addon.
1 Like

I’m wondering (a little daunted after banging my head against this one) if these commands Mariabd backup/restore could be used from within the addon’s container, backing up and restoring using an exposed hass share.