By default, the setup in our Home Assistant installation has been to use the SQLite database. But there is a slightly faster (and better?) Database, namely MariaDB.
Fortunately, setting up MariaDB on Home Assistant is a very easy job. BUT, be aware that when you do, you will lose the history you have in your database. This will be reset.
Setup
Before we start – remember to take a backup. Always backup!
To install MariaDB, go to Add-ons and search for MariaDB. Click install.
When installed, make sure the “watchdog” is turned on.
Important – then change the default password. Go to configuration and select a new strong password.
Then start MariaDB (under info). Check under log that it starts properly.
The next thing to do is update your Home Assistant configuration file. Here it is important that we enter information about the new database.
Open configuration.yaml with a text editor (eg file editor, visual studio or another text editor).
# Change the username,password and database name as required
recorder:
db_url: mysql://homeassistant:password@core-mariadb/homeassistant?charset=utf8mb4
Save the file
Check that the configuration file is correct by using the “Check configuration” function in the Home Assistant.
If everything is OK – restart Home Assistant.
That was it – now Home Assistant runs on MariaDB instead of the standard SQLite database. Over time, you will notice that it goes quickly, even if the database becomes larger and more history is stored in it.