Saturday, April 03, 2010

MDL: How to Share Databases with Multiple XBMC HTPCs

I’ve raved about how great XBMC is already.  Just to demonstrate how truly great it is, I went out and bought a Nettop so that I could install XBMC on my primary TV.

The one problem with this setup is that each install of XBMC maintains a separate database of content.  This is problematic for a couple of reasons.

First, I have OCD really bad and it bugs me beyond belief if the pictures, posters and details associated with all of the music, movies and TV shows are out of whack.

Second, XBMC keeps track of what you have already watched and you can choose to hide that content if you wish.  This feature isn’t all that useful if it only tracks watched content on a TV by TV basis.

So what is the solution?  It turns out that XBMC can be configured to run off of MySQL.  And since MySQL is designed for use by more than one connection, more than one XBMC can be setup to use a single database!

I am well adept at Google-Fu but couldn’t find any decent documentation on how to set this up so it took me some time.  But don’t fret, my sweat is your gain.

Step 1: Download and install MySQL (default everything is fine).  I’m running Windows so downloaded the Windows Community version 5.1.45.  The instructions will reflect this setup, but if you are running linux you should be smart enough to translate from Windows to *nix anyway.

Step 2: Once MySQL is installed and running, log into the database by opening a command prompt and typing: ‘mysql –u root –p’

Step 3: Create a user xbmc with password xbmc: ‘CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';’

Step 4: Create a couple databases:

“CREATE database xbmc_video”
“CREATE database xbmc_music”

Step 5: Grant the new user access to create and modify a new database:  “GRANT ALL ON *.* TO 'xbmc';”

note: yes, I am fully aware that there are more secure ways to accomplish this, but its a media database for Christ’s sake!

Step 6: Create a file called advancedsettings.xml and place it in %appdata%\xbmc\userdata\

Step 7: setup advancedsettings.xml to look just like this.  Note, if you didn’t follow my directions exactly you will need to modify the details to make your setup.

<advancedsettings>
    <videodatabase>
        <type>mysql</type>
        <host>localhost</host>
        <port>3306</port>
        <user>xbmc</user>
          <pass>xbmc</pass>
          <name>xbmc_video</name>
    </videodatabase>
    <musicdatabase>
        <type>mysql</type>
        <host>localhost</host>
        <port>3306</port>
        <user>xbmc</user>
          <pass>xbmc</pass>
          <name>xbmc_music</name>
    </musicdatabase>
</advancedsettings>

Step 8: Start XBMC and it will create the database for you. 

Step 9: Configure advancedsettings.xml on your second copy of XBMC making sure to change the ‘host’ entry to be the IP address of the computer hosting MySQL.

And there you go, a single copy of the database that can be shared by many computers running XBMC!

If you have spent a lot of time getting all of your metadata setup exactly the way that you want it, you can export the library before you start and import it when you are complete so that you don’t have to start over.

I also discovered one last benefit to sharing a DB on multiple computers.  The ‘New Content’ is synced on all of the hosts if you have that feature turned on.

One final gotcha – if you are using Windows you have to setup your content using SMB shares and not local drives.  XBMC doesn’t handle the ‘/’ characters correctly yet in MySQL.

Enjoy!  Hopefully I saved you a little time.

Technorati Tags: ,,

No comments:

Post a Comment