Setting Up A Shared XBMC Library

Although I only have a single device running XBMC, I've set up a shared library mainly so that I can reinstall RaspBMC (or switch to OpenElec, etc) whenever I want without having to worry about the library.  Another benefit is that I can run the shared library using MySQL (stored on a USB Hard Drive) on a BeagleBone Black - with a more powerful CPU, and directly connected to my media!

Server-side setup

This is on a BeagleBone Black running Debian...

Install MySQL:

apt-get install mysql-server

And set a secure root password when requested!

Edit /etc/mysql/my.cnf to allow connections from the local network, rather than just from localhost (change the "bind-address" to the server's IP address, 192.168.1.123 in the example):

sed -i '/bind-address/c\bind-address = 192.168.1.123' /etc/mysql/my.cnf

Restart MySQL:

service mysql restart

Connect to MySQL (type in your root MySQL password when requested):

mysql -u root -p

Create a MySQL user for XBMC (obviously you can select your own password if you want), and give the user full access to any databases (this can be restricted later if you want):

CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';
GRANT ALL ON *.* TO 'xbmc';
quit

Client-side setup

This is on a Raspberry Pi running RaspBMC...

Create or edit the advancedsettings.xml file in XBMC's userdata folder - ~/.xbmc/userdata/advancedsettings.xml

Insert the following (using the correct IP address for the server, and password for the xbmc MySQL account):

<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>192.168.1.123</host>
    <port>3306</port>
    <user>xbmc</user>
    <pass>xbmc</pass>
  </videodatabase> 
  <musicdatabase>
    <type>mysql</type>
    <host>192.168.1.123</host>
    <port>3306</port>
    <user>xbmc</user>
    <pass>xbmc</pass>
  </musicdatabase>
</advancedsettings>

If you want, you can also move a number of XBMC's settings files to be stored (and shared) remotely by adding extra settings to this file (before the </advancedsettings> tag), e.g.:

<advancedsettings>
  <videodatabase>
  ...
  </musicdatabase>
  <pathsubstitution>
    <substitute>
      <from>special://profile/playlists/</from>
      <to>nfs://192.168.1.123/share_path/xbmc/userdata/playlists/</to>
    </substitute>
  </pathsubstitution>
</advancedsettings>