Make-Use of FBX for KODI Database

FBX comes bundled with a great UPNP server: minidlna. The downside is, although we have a running server, minidlna does not have any bells and whistles for catagorizing, downloading media content, or even following where you left off when watching your last movie or show.

Many of you may have heard of Kodi. It’s a really good home theatre software that runs on a variety of platforms and, it’s fully open source! Nevertheless, Kodi doesn’t have server side to it (apart from a third party one that I didnt really want to get into). It’s just a client to serve your media off your drive or NAS.

Owning my own “home-server” I wanted it so that I could access my media (along with its artwork and other bells and whistels) and have it so that I could start watching my favorite movie from one device then continue on another without having to note down where I left off. I’m running my server on a SBC pie, so juice of was the essence as I didnt want a media server streaming/downsizing videos either.

I did a bit of digging on the Kodi wiki and forums and discovered that you could store it’s database on your server and make it so that other Kodi clients could access the same database. This would give me what I wanted (no performance issues with all the functions) - it wasn’t too difficult either. Here are the steps I followed to get things running.

In principal (TL;DR), I installed mariadb (MySQL) from the debian repo and made it so that my Kodi clients accessed this database for keeping their data.

There are many sources on how to install the mariadb. The one I used was here. For configuring Kodi, I used the wiki here. Unfortunately Kodi is only made to run with mysql so I couldnt make use of sqlite or postgres and came out with a third db on the same server : (

Before you continue, have your media archive on your FBX server in a way that you can reach it with SMB. I found that Kodi plays well with SMB - (contrary to UPNP it can read/write to it). Adding your media archive ( and related paths) to Kodi is out of scope here, I assume you can do that.

STEP 1: Installing mariadb

  • Log on to your FBX and do a sudo apt update.
  • Install mariadb with sudo apt install mariadb-server
  • When the installation is complete, you have to secure it with sudo mysql_secure_installation.
    Apart from changing root password, you can answer no to all questions. When you change your root password, note it down (I would prefer not to use the same password I used to logon to my FBX). During the configuration, mariadb will ask you questions on clearing the test database and any other data related so it can be ready for production. Answer yes to all these questions to have a clean and fresh start.
  • Edit the mariadb server configuration so that it can only be accessed from within your local network.
    sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
    Here, change bind-address = ***.***.***.*** so that it points to your FBX local IP. Once done, save and exit.
  • Restart mariadb with sudo systemctl restart mariadb
  • Create a user for Kodi to access this database. The Kodi client will create a database so you dont need to create anything. Just a user will do.
    In terminal mysql -u root -p.
    Once entered, create a user with CREATE USER 'kodi' IDENTIFIED BY 'kodi'; and press enter.
    Give the user necessary privileges with GRANT ALL ON *.* TO 'kodi'; (enter) and flush all privileges with flush privileges; (enter).
    You can exit mariadb to shell with \q (enter)

With the above steps, your database is ready to use. Now, time to put in place your firewall rule so your FBX allows connection to MySQL.

STEP 2: Adjusting Firewall
Run cockpit and go to Networking>Acitve Zone and click on Add services for your Internal network. Here, type in mysql which is predifned for port 3306 and add it to your list. Restart your firewall (toggle on and off from cockpit).

You’re ready to configure Kodi clients to access your FBX database created for them.

Step 3: Kodi First Connection
Everything from hereon is to do with the computers/phone/tv’s you install Kodi on (nothing to do on your FBX server).
I started off with the Kodi client installed on my Debian laptop (apt install kodi), and had my Movie, TV Shows and Music archives addressed to it.

  • Quit Kodi and on your laptop, create an advancedsettings.xml file (with any text editor) with the following:
<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>***.***.***.***</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </videodatabase> 
  <musicdatabase>
    <type>mysql</type>
    <host>***.***.***.***</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </musicdatabase>
  <videolibrary>
    <importwatchedstate>true</importwatchedstate>
    <importresumepoint>true</importresumepoint>
  </videolibrary>
</advancedsettings>

replace ***.***.***.*** with your FBX local IP

  • place this file under
    ~/.kodi/userdata/ in linux
    /Profiledata in android (with android, use Kodi’s internal file browser to overcome permission issues).

  • Start Kodi, and scan your media archive.
    Kodi shall scan your archive and index everything to the mariadb database running on your FBX.

STEP 4: Add more Kodi clients:
Once one of your clients have scanned and indexed your media, just copy the same advancedsettings.xml file to your other clients and you should see that all the clients will be running in sync.

Good luck!

3 Likes