Moving sensitive information from configuration.yaml to secrets.yaml NOT working!

My original lines in the configuration.yaml for the MariaDB:

recorder:
  db_url: mysql://homeassistant:1q2w3eAZSXDC@core-mariadb/homeassistant?charset=utf8mb4
  purge_keep_days: 30

in my configuration.yaml NOW I have this:

# Credentials for the database MariaDB
recorder:
  db_url: mysql://!secret mariadb_user:!secret mariadb_password@!secret mariadb_host/!secret mariadb_db?charset=!secret mariadb_charset
  purge_keep_days: 30

and in my secrets.yaml I got this:

#MariaDB credentials:
mariadb_user: homeassistant
mariadb_password: 1q2w3eAZSXDC
mariadb_host: core-mariadb
mariadb_db: homeassistant
mariadb_charset: utf8mb4

why is not working??
I started getting this errors:

Can someone help me get it right? I know there is NO need for secrets: !include secrets.yaml as it is included by default. Also, tryed changing the file from secrets.yaml to secret.yaml and that did not work so I reverted it back with the S

Any help will be appreciated! Thank

None of the !xxx directives can be combined with other strings like that. You need to make the whole db_url value into one single secret.

recorder:
  db_url: !secret mariadb_url
  purge_keep_days: 30

I think that the secret substitution is for a single value substitution in a key:value pair.

Try this:

# Credentials for the database MariaDB
recorder:
  db_url: !secret myDatabase
  purge_keep_days: 30

And in secrets:

my_database: mysql://homeassistant:1q2w3eAZSXDC@core-mariadb/homeassistant?charset=utf8mb4

Thank you! It all worked out well with your advice!

P.S. Just had to make sure whatever I put on the record secret as a name like

myDatabase

As in your example. It has to be the exact same in secrets.yaml :slight_smile: I see @stevemann has put myDatabase in the configuration.yaml line BUT my_database in the secrets.yaml