If you use XBMC and you have a Synology NAS device, then you ought to think about using the NAS to host not only your music and videos, but also your MySQL database! The Synology has built in support for MySQL and it takes only a few minutes to set it up for XBMC. This will allow you to use multiple XBMC installations and share the same database and thumbnails. In my case I use an Apple TV 2nd gen in the living room with a Crystalbuntu AppleTV 1st gen in the media room. I also have a couple of windows installs that I can use to either watch movies anywhere in the house, or just to manage the library from my desktop.
The main benefit of a MySQL setup are that there is only ever one place where you will need to update TV Show and movie information, so no matter what devices does the scraping, each device reaps the benefits! But, the reason I like it is because I can watch something upstairs and stop in the middle and then resume from any other XBMC player in the house. And, if I ever need to re-install one of my devices, there is no need to re-scrape all of my media. I just put a few config files in the userdata folder and everything is just the way it was before.
Enough with the why…How do you do it??
Part I – Installing phpMyAdmin on a Synoogy NAS
Since I like to keep things easy we will install phpMyAdmin on the Synology and then enable MySQL for Web Station. phpMyAdmin is graphical interface to MySQL and makes things very easy to manage later. This used to be a complicated task, but ever since DSM 3.2 (the Synology OS) phpMyAdmin is available as an out-of-the-box plugin package, so it could not be more simple!
Here is a video on how to get phpMyAdmin installed on your Synology NAS
Or… if you’re old school… Here is a text explanation…
Step one is to enable MySQL and the Web Station interface on the Synology.
Just open the control panel choose “Web Services.”
In the Web Services window, check “Enable Web Station” and “Enable MySQL.”
Next, we will install the phpMyAdmin package for Synology.
Once Web Station and MySQL are turned on, open the “Admin” panel with the arrow button in the top left corner of the page.
From within the Admin panel, choose the “Package Center” and click on the “packages tab.
Scroll to the bottom and find the phpMyAdmin package and click “install.”
Once is is fished installing, click on the “Installed” tab and click “Run” to start phpMyAdmin.
Now, go back to the admin panel and there should be a new phpMyAdmin icon. Click it to open a new browser window and enjoy phpMyAdmin goodness!
Note – It did not work if you cannot see this icon!
Congratulations! You now have a centralized MySQL database!
Part II – MySQL Configuration
This process used to much more difficult involving the creation of users and databases with command lines and all sorts of stuff… Now, it s two step process and only requires a single user! Check out the video for a complete walk though or keep reading for all the details.
So, first step, login to phpMyAdmin.
In the default window for MyPHP Admin, locate the “Priveleges” tab, and click it.
This will give you a list of the current database users and the option to add new users to the database. Click “Add a new user” at the bottom:

Give the user a username of “xbmc” and the same password, or one of your choice. I just use xbmc to keep it easy. Do not add anything for host. In the middle section, make sure “Grant all privileges on wildcard etc…” is checked. In the last section, select “Check All and then click GO!
You should see a confirmation saying that all went well…
Finally – And this is important, some older guides say that you need to also create databases, but this is now wrong! XBMC will create the databases for you, all you need to do is create the user and then let XBMC do the rest. If a database exists with the same name that XBMC expects to find, XBMC will try and use it, and if it is empty, XBMC will fail to connect and throw a ton of errors about “unable to upgrade database…”
That’s it! MySQL is setup.
Part III – Client Configuration and Path Substitution
Now that MySQL is setup, we need to do a couple of things on the AppleTV, Linix box or Windows box to make Thumbnals work right. By default all of the XBMC thumbnails are stored locally in the file system of the player but we want all of our XBMC boxes to share one centralized thumbnails folder. If this is not done, only the player that does a library scan can ever display the thumbnails. So, if you were to scrape on one TV, and then go to another one, all of the fan art and thumbnails would be missing and the GUI would look terrible. There are a couple of ways to do this and some of them depend on the version of your software, but right now all currently released versions of XBMC (Eden and Eden Betas) that work on the ATV1 and ATV2 support path substitution. If you need to use a symbolic link for an older build of XBMC I can explain it.. But its tedious… So I am gong to ignore it for now.
The easy way (works with) :
- An Apple TV 1 using Crystalbuntu with the July 2011 update or better (not using Dharma)
- An Apple TV 2 using 10.0-7 or above (11.0 or Eden Betas are best)
- Just about anything using an 11.0/Eden build
You can do this the easy way by adding a section to the advancesettigns.xml file for XBMC. The Advanced settings will probably not yet exist on your ATV2 or a windows/Linux install but Crystalbuntu (ATV1 via Sam’s image) will include the file already. The advancedsettigns.xml file is used by XBMC to enable features that are otherwise hidden, such as the MySQL shared database. There is no big secret to the file, it is plain text and if it exists in the userdata folder of the XBMC install, it will be read and used.
For the sake of simplicity I will list out generic instructions for Windows, Crystalbuntu and an ATV2… The text and settings are all the same but there are minor differences in where the file is located and what may or may not be in the file already.
For Windows
(This is covered in depth in the video above)
The file is not created by default and must be located in the roaming profile. typically:
c:\users\[USERNAME]\appdata\roaming\XBMC\userdata
Go to that folder and create a text file named “advancedsettings.xml. Use notpad to edit the file and eneter the following text:
<advancedsettings>
<videodatabase>
<type>mysql</type>
<host>192.168.1.XXX</host>
<port>3306</port>
<user>xbmc</user>
<pass>xbmc</pass>
<name>xbmc_video</name>
</videodatabase>
<musicdatabase>
<type>mysql</type>
<host>192.168.1.XXX</host>
<port>3306</port>
<user>xbmc</user>
<pass>xbmc</pass>
<name>xbmc_music</name>
</musicdatabase>
<pathsubstitution>
<substitute>
<from>special://masterprofile/Thumbnails/</from>
<to>smb://192.168.1.XXX/media/Thumbnails/</to>
</substitute>
</pathsubstitution>
</advancedsettings>
NOTE: In your setup replace all of the IP addresses with the address of the NAS/Shared folder and also check the path for the thumbnails. I am showing an SMB share here though it can also be done with NFS as well. In my case this assumes I have a root shared folder called “media” and a folder inside named “Thumbnails” and that it has public read/write permissions. The thumbnail folder must be writeable and case matters!
For an ATV1 with Crystalbubntu or some Linux installs:
You will need to add a few lines to the existing file (or create a new one in Linux). For Crysatlbuntu, you must have already booted the ATV and actually gotten all the way to XBMC so that Sam’s scripts will have updated the file system and included the most recent advancedsettigns.xml update. Basically, boot all the way once, reboot a couple times and then follow the instructions below. If you have used your AppleTV for a while, just re-boot once to be safe.
Use Putty to SSH into the ATV2 with a userID of ATV and a password of ATV.
Type:
sudo nano /root/.xbmc/userdata/advancedsettings.xml
password is atv again
Once nano opens you should see an XML file with this (and possibly more) in it:
<advancedsettings> <useddsfanart>true</useddsfanart> </advancedsettings>
Its possible that the file may be brand new and empty… In either case you will need to add a new section between a pair of <advancedsettings> and </advancedsettings> tags. If there is noting in the file, you will need to put <advancedsettigns> above and </advancedsettigns> below what is added next.
Add the following:
NOTE: The file must start with </advancedsettigns>
<videodatabase> <type>mysql</type> <host>192.168.1.XXX</host> <port>3306</port> <user>xbmc</user> <pass>xbmc</pass> <name>xbmc_video</name> </videodatabase> <musicdatabase> <type>mysql</type> <host>192.168.1.XXX</host> <port>3306</port> <user>xbmc</user> <pass>xbmc</pass> <name>xbmc_music</name> </musicdatabase> <pathsubstitution> <substitute> <from>special://masterprofile/Thumbnails/</from> <to>smb://192.168.1.XXX/media/Thumbnails/</to> </substitute> </pathsubstitution>
NOTE: The file must end with </advancedsettigns>
NOTE: In your setup replace all of the IP addresses with the address of the NAS and also check the path for the thumbnails. I am showing an SMB share here though it can also be done with NFS as well. In my case this assumes I have a root shared folder called “media” and a folder inside named “Thumbnails” and that it has public read/write permissions. The thumbnail folder must be writeable and case matters!
FOR AN ATV2:
The file is not created by default and must be located in:
/private/var/mobile/Library/Preferences/XBMC/userdata
So the command to create/edit the file is:
cd /private/var/mobile/Library/Preferences/XBMC/userdata/ sudo nano advancedsettings.xml
Add the following text:
<advancedsettings>
<videodatabase>
<type>mysql</type>
<host>192.168.1.XXX</host>
<port>3306</port>
<user>xbmc</user>
<pass>xbmc</pass>
<name>xbmc_video</name>
</videodatabase>
<musicdatabase>
<type>mysql</type>
<host>192.168.1.XXX</host>
<port>3306</port>
<user>xbmc</user>
<pass>xbmc</pass>
<name>xbmc_music</name>
</musicdatabase>
<pathsubstitution>
<substitute>
<from>special://masterprofile/Thumbnails/</from>
<to>smb://192.168.1.XXX/media/Thumbnails/</to>
</substitute>
</pathsubstitution>
</advancedsettings>
Exit Nano and reboot the ATV2.
Part IV – Sources Setup
Finally, you will likely want to set-up the XBMC Sources on your primary player or some other XBMC device that is easy to work with and then copy the sources.xml file from that device and paste it to all of your other devices. The sources.xml file points XBMC to all of your shared folders and if you use a shared database then you need to have exactly the same shares (with identical paths) on each XBMC box as well. This is also the case for thumbnils since they are organized based on the full path name. That is to say that even though “smb://192.168.1.101/media/movie.avi” and “smb://NAS/media/movie.avi” may point to the same file, they have a different absolute path and therefor will not share the same database entry or thumbnail. This is also the case if one path is SMB and another is NFS. All players that share a database must use the same path to each file. And if you start with SMB and then upgrade to NFS, you will need to re-scan your library since all of the paths will change. There is a way around this, but its tedious.
I use all SMB shares since I know those will work on all of my players but I have tested NFS and its good too. And keep in mind one more time, the protocol for each share must be the same on each box sharing a database, so you cannot do NFS one one box and SMB on another.
That’s it, enjoy!







