Kodi - Remote database for distributed Kodi installations

The target platform for this tutorial is a Synology DS416J and a Raspberry PI running openelec.

Create remote database

Install phpmyadmin (which will install MariaDB automatically)
In a new installation of phpmyadmin remove the "any" accounts.

Click on Add new user

User name: kodi
Click Generate password (copy and paste it for later use!)
Global Priviliges: all

Configure Kodi

4. In the Kodi GUI open the openelec Settings under Add-Ons/Programs

5. Open Network/Advanced Network Settings and enable Wait for network before starting Kodi
     This is required as Kodi connects to the DB only during startup. Alternatively you can try the following command on other platform (haven't tested it myself!):

sudo systemctl enable connman-wait-for-network.service

6. Create a new file named advancedsettings.xml

openelec installation: Open SSH connection (root / openelec) and create ~/.kodi/userdata/advancedsettings.xml

Windows Store installation: Put the file in %USERPROFILE%\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalCache\Roaming\Kodi\userdata\advancedsettings.xml

Fill in the correct IP address of your SQL server and the password for your user kodi.
Btw: Synology uses Port 3307 for MariaDB 10 (instead of default port 3306)

<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>***.***.***.***</host>
    <port>3307</port>
    <user>kodi</user>
    <pass>**********</pass>    
    <name>kodi_movies</name>
  </videodatabase> 
  <musicdatabase>
    <type>mysql</type>
    <host>***.***.***.***</host>
    <port>3307</port>
    <user>kodi</user>
    <pass>**********</pass>
    <name>kodi_music</name>
  </musicdatabase>
  <videolibrary>
    <importwatchedstate>true</importwatchedstate>
    <importresumepoint>true</importresumepoint>
  </videolibrary>
</advancedsettings>
7. Restart Kodi to connect to the new database.

8. Check your log file for error messages

openelec installation: ~/.kodi/temp/kodi.log    

Windows Store installation: %USERPROFILE%\AppData\Local\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalCache\Roaming\Kodi\kodi.log

Hint: If everything runs successfully, Kodi v17 (Krypton) will create two databases named MyMovies107 and MyMusic60. The next version (as of Q2 2018 still in Alpha stage) will use different names. See: https://kodi.wiki/view/Databases

Clone your Kodi installation

1. Copy the following files (if present) to your your second / third ... Kodi installation
  • advancedsettings.xml
  • sources.xml
  • mediasources.xml
  • passwords.xml
  • favourites.xml

2. To have the other Kodi client(s) also benefit from the already downloaded/cached art thumbnails (untested!):

  • userdata/Database/Textures13.db
  • userdata/Thumbnails/*