Guides

Kodi – sharing the library on the local network

If you have more than one device with a kodi player in your home network, you would definitely like to have a shared library, so that the information in the library between devices syncs just like in plex. Using shared library databases allows you to store information about your video or music library in a central database so that multiple devices can access the same information simultaneously.

In the home network, this is possible using the MySQL protocol. Both MySQL and MariaDB use it. More and more Linux distributions are switching to MariaDB and drop MySQL. However, both are compatible with each other.

For library sharing to work, one of the devices must have MySQL server installed, and the other devices will connect to it. The server can run on both windows and linux. I prefer Ubuntu.

It is important to remember that the same version of Kodi should be installed on each device.

Installation MySQL server

sudo apt-get install mysql-server

A password must be provided during installation.

When using MySQL8 or higher (Ubuntu 20.04 or later), add the following line at the end of /etc/mysql/mysql.conf.d/mysqld.cnf:

default_authentication_plugin=mysql_native_password

Restart MySQL server:

sudo service mysql restart

Get into the MySQL command line utility:

mysql -u root -p

Create a kodi user for MySQL:

CREATE USER 'kodi' IDENTIFIED BY 'password';

MySQL8 or newer:

CREATE USER 'kodi' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT ALL ON *.* TO 'kodi';
flush privileges;
\q

Konfiguracja klientów kodi

Client configuration consists in creating the advancedsettings.xml file and copying it to the Userdata directory of each client.

Depending on the operating system, the Userdata directory is in the following locations:

Operating systemUserdata folder location
Android Android/data/org.xbmc.kodi/files/.kodi/userdata
iOS /private/var/mobile/Library/Preferences/Kodi/userdata/
LibreELEC /storage/.kodi/userdata/
Linux ~/.kodi/userdata/
Mac/Users//Library/Application Support/Kodi/userdata/
Nvidia Shield (SMB) smb://<nvidiashieldurl>/internal/Android/data/org.xbmc.kodi/files/.kodi/userdata
OSMC /home/osmc/.kodi/userdata/
tvOS /private/var/mobile/Library/Preferences/Kodi/userdata/
Windows %APPDATA%\Kodi\userdata
Windows Portable <Install location chosen by you>\portable_data\userdata\
Windows Xbox %LOCALAPPDATA%\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalCache\Roaming\Kodi\

The advancedsettings.xml file should be as follows:

<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>***.***.***.***</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>password</pass>
  </videodatabase> 
  <musicdatabase>
    <type>mysql</type>
    <host>***.***.***.***</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>password</pass>
  </musicdatabase>
  <videolibrary>
    <importwatchedstate>true</importwatchedstate>
    <importresumepoint>true</importresumepoint>
  </videolibrary>
</advancedsettings>

After that, you need to add video sources to your clients in a format recognized by kodi. These will be network locations, for example:

smb://192.168.1.20/Videos/

After that, the shared library should work.