Problem re-adding MariaDB (!secrets not working)

Hello everyone,
I was using MariaDB before deleting my database and wanted to use it again. But I am running into problems.

I setup MariaDB again but cannot use !secret. When I enter secrets and hit save I get (usernames and password removed in my quotes):
Logins:

Failed to save add-on configuration, Missing option ‘logins’ in root in MariaDB (core_mariadb). Got {‘databases’: [‘homeassistant’], ‘rights’: [{‘username’: ‘’, ‘database’: ‘homeassistant’}]}

Rights:

Failed to save add-on configuration, Missing option ‘rights’ in root in MariaDB (core_mariadb). Got {‘databases’: [‘homeassistant’], ‘logins’: [{‘username’: ', ‘password’: ‘’}]}

It works without using secrets, but not with secrets.
I have rebooted, uninstalled, reinstalled, restartet…

Anybody know if there is a problem with this?
It used to be so easy when you simply loaded the yaml file and rebooted… :frowning:

Thank you
Alex


EDIT:
I think the uninstall maybe isn’t working properly. In the logs I found

22-09-10 17:05:03 ERROR (SyncWorker_6) [supervisor.docker.manager] Can’t create container from addon_core_mariadb: 409 Client Error for http+docker://localhost/v1.41/containers/create?name=addon_core_mariadb: Conflict (“Conflict. The container name “/addon_core_mariadb” is already in use by container “b46ee767161c41c74476444298de235ae4648cab332b714089c6ccbbc81f69e6”. You have to remove (or rename) that container to be able to reuse that name.”)
22-09-10 17:05:03 ERROR (MainThread) [supervisor.addons.addon] Watchdog restart of addon MariaDB failed!
22-09-10 17:05:03 ERROR (SyncWorker_2) [supervisor.docker.manager] Can’t start addon_core_mariadb: 404 Client Error for http+docker://localhost/v1.41/containers/b46ee767161c41c74476444298de235ae4648cab332b714089c6ccbbc81f69e6/start: Not Found (“No such container: b46ee767161c41c74476444298de235ae4648cab332b714089c6ccbbc81f69e6”)
22-09-10 17:05:03 ERROR (MainThread) [supervisor.addons.addon] Watchdog restart of addon MariaDB failed!
22-09-10 17:05:07 ERROR (MainThread) [supervisor.services.modules.mysql] There is already a MySQL service in use from core_mariadb

You’re not showing us your config, but you should use !secret (singular) and not !secrets (what you said).

I am using !secret. At least that is what I have always used. I corrected the plural form in my inital post.

databases:
  - homeassistant
logins:
- username: !secret mariadb_homeassistant_user
  password: !secret mariadb_homeassistant_password
rights:
- username: !secret mariadb_homeassistant_user
  database: homeassistant

After again uninstalling MariaDB I am seeing this in the logs

Error executing query SELECT table_schema “database”, Round(Sum(data_length + index_length) / 1024, 1) “value” FROM information_schema.tables WHERE table_schema=“homeassistant” GROUP BY table_schema LIMIT 1;: (MySQLdb.OperationalError) (2005, “Unknown MySQL server host ‘core-mariadb’ (-2)”) (Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation)

I think I solved it myself.

For one I deleted the entry in config/.storage/core.device_registry. There still was a MariaDB entry in there (also an entry for the uninstalled phpMyAdmin.
Not sure if this is crucial, but the error in the log seems to have disappeared.

More importantly:
The move to UI seems to be incomplete for MariaDB integration.
you have to select “Edit YAML” if you want to use secrets. The exact same code works if you copy it into the edit in yaml mode.

2 Likes

Hi! I am having the same issue and using the edit yaml option. Any idea what else could be the issue? I copied your code and adjusted it to my naming and secrets.yaml but still get an error:

Failed to save add-on configuration, Unknown secret ‘mariadb_user’ in MariaDB (core_mariadb). Got {‘databases’: [‘homeassistant’], ‘logins’: [{‘username’: ‘!secret mariadb_user’, ‘password’: ‘!secret mariadb_pass’}], ‘rights’: [{‘username’: ‘!secret mariadb_user’, ‘database’: ‘homeassistant’}]}

Τhis is unbelievable, I don’t know why, but ONLY in this “corner” of HA !secret needs double quotes. Eg.: "!secret YOUR_SECRET_HERE"… Go figure.
Also the UI implementation here is broken, as noted above.
Finally I’m also encountering this There is already a MySQL service in use from core_mariadb · Issue #2742 · home-assistant/addons · GitHub but MariaDB is running and NPM which uses it works fine. I’m not using MariaDB for the recorder, so I’m not sure how it would behave if I did.

2 Likes

Hello,
I had the same issue.
With “Edit YAML” to use secrets works for me!
Thanks!

Because this came up in Google Search but not the solution for me.

I was doing a first-time setup which means I added the entries to the secrets.yml file and tried to add it to the MariaDB configuration via YAML but got the same “unknown secret” error message.

The solution for me was to enter the password in plain text in the configuration, start MariaDB for the first time, then convert it to use the secrets using the quotes. It then accepted it when I saved the change.

2 Likes