MySQL: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
(→‎Share your files: Both should work on most major desktop OS's)
Line 19: Line 19:
Depending on the operating system of the system your media files will sit on you will need to share your files.
Depending on the operating system of the system your media files will sit on you will need to share your files.
Using the following guides:
Using the following guides:
* [[Windows File Sharing (SMB/SAMBA/CIFS)]] for Windows
* [[Windows File Sharing (SMB/SAMBA/CIFS)]]
* [[Network Filesystem (NFS)]] for Linux
* [[Network Filesystem (NFS)]]
*[[NAS (Network Attached Storage)]]
* [[NAS (Network Attached Storage)]]


==Setting up the MySQL server==
==Setting up the MySQL server==

Revision as of 11:42, 18 November 2011

What is synchronisation for XBMC?

  • Simply put it allows you to store information about your whole video library in a central database, so that multiple instances of XBMC can access the same information at the same time. The video and music files remain in the same place on your shared folders/HDD's.

Is it for me?

  • If you have more than 1 instance of XBMC running on your network then probably yes it's for you.

What kind of information is stored, what primary benefits does this give?

  • Watched and unwatched status for your files.The little tick boxes beside your videos in XBMC.
  • Stop point for part watched files. This also allows you to watch some of the file in 1 room then finish watching it in another room without having to find the part where you were at.
  • Fan art and thumbnails can also be stored. See below.
  • If you have more than 1 instance of XBMC on your network you will have lowered your storage requirements by keeping fanart, thumbnails, plot, cast, and other data about your files in just one place on your network instead of having a copy on each PC.

Selecting a server

First you'll need to choose which of your XBMC devices (or NAS) will be the MySQL server. The server needs to be on 24/7 or have wake-on-lan (preferably the former), and needs to have a local static IP. You will probably want the XBMC device that is hosting most or all of your videos and music to also be the MySQL server, but this is not required.

Share your files

With more than one instance of XBMC running on your network, you don't want the video/music/picture files to be copied on every XBMC PC in your network. It would be a waste of resources (HDD space) and would severely hinder any attempt at syncing. So you need to share the files. Sharing is a very important step before continuing with this HOW-TO.

Depending on the operating system of the system your media files will sit on you will need to share your files. Using the following guides:

Setting up the MySQL server

On a computer

MySQL can be installed on just about every major OS:

  1. Download a copy of MySQL server for your OS from http://dev.mysql.com/downloads/mysql/
  2. Run the installer and select the Standard configuration
  3. Create a password when asked
  4. Select that you want the database to have network access
    Linux: Comment out the following line in the MySQL configuration file (/etc/mysql/my.cnf)
    1. from: bind-address = 127.0.0.1
    2. to  : #bind-address = 127.0.0.1
  5. Get into the MySQL command line interface.
    Windows: Open the "MySQL Command Line Client" from the MySQL start menu
    Mac OS X:
    Linux:
    1. Type in: CREATE USER 'xbmc' IDENTIFIED BY 'xbmc'; and press return
    2. Type in: GRANT ALL ON *.* TO 'xbmc'; and press return
    I think there are some "speed up commands" that can be issued here to help make the MySQL queries faster. If so, need to note that here.
  6. Close out the command line tool

On a NAS

MySQL can also be installed on some network-attached storage (NAS) device devices. See one of the following guides for more info:

Setting up XBMC

advancedsettings.xml:
<advancedsettings>
    <videodatabase>
        <type>mysql</type>
        <host>***.***.***.***</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
        <name>xbmc_video</name>
    </videodatabase> 

    <musicdatabase>
        <type>mysql</type>
        <host>***.***.***.***</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
        <name>xbmc_music</name>
    </musicdatabase>
</advancedsettings>
  1. Open XBMC on the computer that has the library you want to share (If you have not created a library yet you can skip this step)
    Notice: If your video library contains local file paths (e.g. C:\Videos\) and is not shared, instead of network file paths (such as SMB shares, see Share your files above) then this will not work.

You will need to convert your exported library files by following these instructions.

    1. Export the Video Library by doing the following:
      1. Go to System/Settings -> Video -> Library and select Export library
      2. Select Single file
    2. Export the Music Library by doing the following:
      1. Go to System/Settings -> Music -> Library and select Export library
      2. Select Single file
  1. Create (or add to, if you already have one) an advancedsettings.xml file:
    1. Open up a plain text editor
    2. Copy and paste the text from the right-hand box into a new text document
    3. Replace the two instances of <host>***.***.***.***</host> with local network IP address of your MySQL server
    4. Save the file as advancedsettings.xml
  2. Copy this advancedsettings.xml file you just created to the userdata folder of every XBMC install you want to sync with:
    • Windows XP: Documents and Settings\<your_user_name>\Application Data\XBMC\userdata\advancedsettings.xml
    • Vista/Windows 7: Users\<your_user_name>\AppData\Roaming\XBMC\userdata\advancedsettings.xml
    • Mac OS X: /Users/<your_user_name>/Library/Application Support/XBMC/userdata/advancedsettings.xml
    • iOS: /private/var/mobile/Library/Preferences/XBMC/userdata/advancedsettings.xml
    • Linux: $HOME/.xbmc/userdata/advancedsettings.xml
  3. Open any of your XBMC installs and re-import your library data (If you have not created a library yet you can skip this step)
    1. Import the Video Library by doing the following:
      1. Go to System/Settings -> Video -> Library and select Import library
      2. Select the file you saved from the first step when you exported your video library
    2. Import the Music Library by doing the following:
      1. Go to System/Settings -> Music -> Library and select Import library
      2. Select the file you saved from the first step when you exported your music library
  4. You can now add files and update the library from any of your XBMC boxes and the library for all of them will stay in sync.

Syncing thumbnails and fanart

If you have lot's of files and more than 1 instance of XBMC running on your home network, then you could save gigabytes of storage space, by having the fanart and thumbnails in just 1 network shared location. Save internet bandwidth and time also by not having to re-download the fanart separately for each instance of XBMC.

The Thumbnail folder in XBMC contains both thumbnails and fanart. If you have imported from pre-existing Libraries then you can use your old thumbnail folder to save time on re-downloading images. <- Should be true if user didn't have to convert any file paths during library export (local to network). Need to explain that here in an easy-to-understand way

add to advancedsettings.xml:
<pathsubstitution>
  <substitute>
    <from>special://masterprofile/Thumbnails/</from>
    <to>REPLACE_THIS_TEXT</to>
  </substitute>
</pathsubstitution>
  1. Share your existing Thumbnail folder or a new folder via NFS, SMB, or AFP. It's easiest to do this from the same computer/device as your MySQL server.
    • Windows XP: Documents and Settings\<your_user_name>\Application Data\XBMC\userdata\Thumbnails\
    • Vista/Windows 7: Users\<your_user_name>\AppData\Roaming\XBMC\userdata\Thumbnails\
    • Mac OS X: /Users/<your_user_name>/Library/Application Support/XBMC/userdata/Thumbnails/
    • iOS: /private/var/mobile/Library/Preferences/XBMC/userdata/Thumbnails/
    • Linux: $HOME/.xbmc/userdata/Thumbnails/
  2. Copy the text from the right hand box and add it to your advancedsettings.xml file, but make sure you add the text before the </advancedsettings> tag at the end.
  3. Note/copy the network path of your shared Thumbnails folder and use that to replace REPLACE_THIS_TEXT.
  4. Make sure all XBMC devices that are being synced have this addition to their advancedsettings.xml file.

Using profiles and MySQL libraries

Note that you can use profiles to switch between a local library and a MySQL library, or even two different MySQL libraries. Also note "roaming profiles" concept for portable device users (including laptops!) to prevent XBMC from freezing up (for example see: forum:92807)