Connecting a second and subsequent PI to MySQL

I have two Raspberry Pis, a version 1 and a version 2. OSMC has just been installed on both of them and they are now running the same version of OSMC. I have a headless NAS on which I have my media and I have set up a MySQL server for sharing the media data. I used PiV2 to set all this up and it all works well, I intend to use PiV1 in another room and have set up the MySQL with that in mind to service both and possibly subsequent units.

Thanks to the MySQL GUI in OSMC I fairly easily set up the connection and have proved it works with PiV2. I have connected PiV1 and set up MySQL on that and have a connection. Through ‘Videos’ on the home screen I am able to add the video source for ‘Movies’ (‘TVShows’ is the same) and through Videos – Files – Movies I can navigate through the media on the NAS and play it, pause, resume stop etc, but no matter what I have tried I cannot get the Movies and TVShows to populate on PiV1 – Movies and TVShows do not appear on the home menu. Update library appears to do nothing. I set up the source correctly with contents and scrapers.

There are a lot of instructions on line as to how to set up MySQL for use on multiple Pi units but there is nothing, that I can find, about once it is set up and the original unit is connected and working how to connect a second and subsequent Pi units to the network so they can use the MySQL data. On connection are they supposed to automatically set up the menus once you point them in the right direction or am I missing something. I have tried reboots and deleting and re-adding the media sources to no avail, I chose refresh from ‘new’ video source while adding it but it didn’t appear to do anything…

The important thing with sharing between 2 Pi’s with a common MySQL is that the media must be available in the exact same place. So for example if your media on the master Pi is mounted at:


then it MUST be mounted at


on the slave Pi.

You do not need to add the sources on the slave Pi, just setting up the connection to the MySQL database and having the media mounted in the same path is all you need.

That’s my preferred method that I’ve been using for years. The ‘recommended’ method is to set the media source on the master Pi to use a network drive, even if it’s locally mounted. So on the master Pi you’d set the source to:


You then do not need to mount it on the slave Pi.

It’s just personal preference, but I like the idea of mounting them in the same place.

There isn’t a ‘Master’ and ‘Slave’ Pi. There are two which are equal and both of which are connected to a separate NAS. The PiV2 is just the one I connected to the NAS first and set the whole thing up with. The PiV1 is another Pi being connected. The location of the media on the NAS is set up NAS/Media/Movies and both Pi units are connected to it as a common source and both see it the same.

I used ‘master’ to be the first Pi. The one with the database.

The second Pi, the ‘slave’ and any other Pi’s added only need the MySQL settings in advancedsettings.xml. You do not need to add any sources so long as the media is available.

You are using a NAS, how are the files mounted to the first ‘master’ Pi? via fstab or was the source setup to nfs:// or smb://?

If you are using smb, make sure you installed Samba on the slave Pi.

I am actually using FTP it works well with the first one and as I said the 2nd PI can see everything and connects it just doesn’t populate the home page menus.

You mentioned that you added the sources on the second Pi. Remove those sources as they are not needed.

You may want to just remove your /home/osmc/.kodi/userdata/sources.xml file, then reboot. (On the second Pi). As long as the MySQL settings are in advancedsettings.xml then you should see everything that Pi 1 can see.

And it appears that I am an idiot. I did as you suggested - removed sources and rebooted nothing. So I checked my my MySQL connection and it seemed OK, but I realised that I put in the FTP password (6 digits min) instead of the MySQL one (four digits) reboot and we’re scanning as I type.

Cool, but the second Pi shouldn’t be scanning (other than getting cover art). It should just see everything.

Possibly that is what it is doing but it is setting itself up. It is ripping through the library pretty quickly.

If you don’t set up sources on other units you will be unable to browse by the File menu. Simply copy advancedsettings.xml sources.xml and passwords.xml (if it exists) from the working Pi to the other installs. copy/paste the files to avoid any differences between them, I keep a “master” file set on the server with all my media on it so when I set up a fresh install the files are readily accessible. I can have a new install up and running in less than 5 minutes

Can anyone put together a simple howto for connecting multiple Pi units to a MySQL data base. There are a lot for initial setup but nothing for afterwards.

The only thing necessary is an advancedsettings.xml that points to the MySQL server. Not really much to write…

This is not actually the case. You can use path substitution in advancedsettings.xml if the path to access the files differs for different devices.

For me, my media files are all on the local hard drive of a Mac which is also the “primary” Kodi install. The library was scanned in on this Mac using local file system paths.

When I later added satellite installs, they access the media files via NFS, so the path differs from the one the server uses. On all installs except the main Mac server install I have a path substitution entry (in addition to the mysql settings) in advancedsettings.xml. Works fine, and avoids having the server unnecessarily connect back to itself via NFS.

So now I am passed the password faux pas things seem to be working. One final question, how do I update library to add new content? Do it on one pi and the other picks up the changes?


What i would do is run osmc on all of them with SAMBA on each and stream from one to all devices on network.

I realize this is an old thread but I have a somewhat relevant question regarding shared SQL database. I have everything working but just need clarification on a couple things. I have a Pi3 running OSMC Kodi 18 as the server, and 2 clients, client 1 is a Vero4k and client 2 is a FireTV Stick. All running Kodi v18. Pi3 has fstab NFS shares. Now my question is about the FireTV, since it can’t connect to media server via fstab NFS mounts it uses the browse based NFS shares to the media server. I understand from reading above that the clients must access the shares the same way so am I better off just maintaining a local database on the FireTV? Obviously the Vero4k has no issue as it’s connecting to the Pi3 with the very same fstab NFS mounts. Also I was unaware that I didn’t have to populate shares on the clients in the files menu as the SQL database will forward the shares properly. Seems like the FireTV may not be able to use the SQL database as it’s not connected to the same mount point as the other 2. Any information would be appreciated. Thanks

Just use path substitution on the FTV instance of Kodi.

I was thinking about that. Do I still need to make a dummy folder to mirror the /mnt folder I use on the Pi3? I assume I would have to redirect the path to match wouldn’t I?

No. Use the file manager to add an NFS source in Kodi on FTV. Then check your .kodi/userdata/ folder and look at sources.xml and you’ll know what location to use in the from line in pathsub. There is no need for the location to actually exist on that device.