Kodi with central database

Multimedia

Kodi offers the possibility to use an external database instead of a local database for the audio, tvshows and movies libraries.

What advantages does this bring?

Just imagine the scenario that you operate several televisions in the house with e.g. LibreELEC / OpenELEC. If each of these devices uses its own database, the maintenance of the same ones becomes increasingly complex. What care?!? …  the maintenance of the tvshows and movie names. The search often does not provide the right data for the corresponding video and you have to do it yourself. But then you do that n times. With a shared database, you only do this once!

Another advantage is that you can see what has already been seen on all Kodi instances. Also, I can stop playback mid-movie on one device and then just resume it from the same spot on another device. A central database makes this possible, too!

Enough blah blah… now how do you do that?

Preamble

But before we really get started, it should be noted that the whole thing only makes sense if the media are also centrally available. I share all my media via NFS and then mount them on the devices. Of course, you make sure that the paths / sources are identical on all devices.

Create database

Kodi supports SQLite and MySQL databases. The latter is the right choice in this case. SQLite is more suitable for the local database on the individual devices and is also used there by default. So you need some central MySQL server. On my home server I’m running MariaDB-10.6.10.

Now we need to create a database including a user account for Kodi. I do it the classic way via the console, but there are also other options such as phpMyAdmin, MySql-Workbench, etc..

In my case, I connect to my server using SSH. Then it continues with MySQL … you log in as “root” in the MySQL server.

mysql -u root -p

Once you are in the MySQL Monitor, let’s start and create a new user:

CREATE USER 'kodi'@'%' IDENTIFIED BY 'supersecret';

Within this tutorial I use the user “kodi” with the password “super secret”. You should at least change the password in your installation!

Now we give the user all rights:

GRANT ALL PRIVILEGES ON *.* TO 'kodi'@'%';
FLUSH PRIVILEGES;

This enables Kodi to create all the necessary databases.

Configure Kodi

The configuration of Kodi is independent of the system underneath. Only the location of the configuration file changes from system to system. You can get more detailed information about the storage location in the Kodi Wiki. In this tutorial I assume a device with LibreELEC.

The whole thing is configured in the “advancedsettings.xml” file. These can be found under LibreELEC / OpenELEC

/storage/.kodi/userdata/advancedsettings.xml

There is now an option to either access the LibreELEC device using Samba (if enabled) or connect using SSH to create/edit the file.

In any case, the file should have the following content:

<advancedsettings>
    <videodatabase>
        <type>mysql</type>
        <host>192.168.3.2</host>
        <port>3306</port>
        <name>kodi_video</name>
        <user>kodi</user>
        <pass>supersecret</pass>
    </videodatabase>

    <musicdatabase>
        <type>mysql</type>
        <host>192.168.3.2</host>
        <port>3306</port>
        <name>kodi_music</name>
        <user>kodi</user>
        <pass>supersecret</pass>
    </musicdatabase>

     <videolibrary>
          <importwatchedstate>true</importwatchedstate>
          <importresumepoint>true</importresumepoint>
     </videolibrary>
</advancedsettings>

Here is a brief explanation of the various settings:

<host></host> - Hostname or IP-Adresse of MySQL server

<port></port> - MySQL Server Port (Standard 3306)

<user></user> - Username (kodi)

<pass></pass> - Password (supersecret)

This completes the configuration and you need to restarts the Kodi instance (LibreELEC). Then it is time to update the database. It is best to do this on one system at first. Then it is sufficient to simply transfer the “advancedsettings.xml” file to the other systems.

Comments

You can use your Mastodon account to reply to this Post.

Reply