How to setup Kodi database on a QNAP NAS.

Kodi and a QNAP (or any NAS) is a dream setup.

It’s an even better setup if you use Kodi on multiple devices in your household and have your media collection on a central ‘server’

One annoyance however can be all your libraries are all out of sync, not knowing what you’ve watched or where you’ve got up to on every device can be a little annoying.

However you can solve this by also having all your Kodi clients connect to one central database so your media library is all in sync across all of your Kodi devices, and best of all. If you are watching something on your Raspberry Pi for example connected up to the main TV and decide to want to go to bed to finish off what your watching, then simply stop playback, go upstairs, pick up your Android tablet, load up Kodi, and not only will it know what episode you were up to on your series, it will start playing that episode from the exact spot of where you stopped it, because all the clients are talking to the same database. This is a game changer in the home media centre setup!

Unfortunately setting this up to work, isn’t as simple as it should be, so while guides exist, some have got a little out of date and require updating, so for my own personal reference and anyone else that wants to do it and is having problems with some guides that are years out of date, here’s how to do it in 2018.

    1. Make sure all your Kodi clients are running the same version, and this goes for in the future to, if one client is updated, make sure you update the others to the exact same version number.
    2. Load up the control panel on your QNAP.
    3. Make sure all the media you want to be in your database is in one major folder and that it’s shared. For example on my QNAP I have a folder called Multimedia, and under that, I have folders called Music, TV Shows & Movies. Use the File Manager tool to create your folders and move folders if need be, it will be a lot quicker doing it on the NAS itself than moving files about using Windows or any other desktop OS.
    4. In control panel under network and file services click on Win/Mac/NFS
      Under Microsoft Networking, click to enable if not already set and click apply. (You can use NFS if you prefer, but I find SMB is actually more reliable. UPDATE: I’m now using NFS as I purchased an Xbox One, and the Xbox version of Kodi can only access NFS shares currently. Whatever method you use ensure you set permissions accordingly for your setup.)
    5. Once all your files are in one place click users.  Create a user account on your QNAP to access your multimedia shares. For simplicity in identifying the user you may simply want to call it Kodi. Giving permissions like the below will be fine, it needs write access as it will also write the thumbnails for the graphics Kodi database to this folder.
    6. Next we need to install MariaDB on the QNAP, In the control panel on the QNAP, click the applications menu (not app centre) and click the SQL server entry.
      Tick the boxes as below and click apply
    7. Before we install phpMyAdmin, click on the web server icon and enable the web server as below and click apply:
    8. Click back onto SQL server, and click the link to install phpmyadmin
      this will take you straight to the phpmyadmin app in the app centre, click the blue button to install it. (Mine says open because I already have it installed)
    9. Once installed click the open link to ensure its working correctly, if you get a https error just click advanced in your browser to bypass.
      The default username and password to login is
      username: root
      password: admin
    10. You should now see something like the below, I’ve cropped my databases on the left out to not confuse you.

      I’d recommend you click on the user accounts button and select the root account which has a YES in the password column, and then select edit privileges.

      Click Change Password

      Enter a new password and then click go.
    11. Next click the SQL tab across the top.
      Enter the following lines of code:
      CREATE USER 'kodi' IDENTIFIED BY 'kodi';
      GRANT ALL ON *.* TO 'kodi';

      Click GO
      And the Kodi user for our database will be created with a password also, of kodi and with enough permissions to create and write to databases.
      If you go back to the user accounts tab, you should now see a kodi user listed

      If you’re concerned about security, change the password as you did for the admin user, just remember what you changed it too when we reference the kodi user again later in this guide.
    12. If you already have a Kodi database you want to use with all your watched and unwatched programs, then we need to export it. If you want to start fresh, or are doing a complete new setup, you can skip this step.
      Click the settings button
      Select Media
      Change the cog at the bottom to Advanced or Expert
      Select Library on the left
      Choose Export Library
      Choose single file
      Choose where to save the file and click OK
      This may take some time depending on how big your library is.

      EDIT: Since originally posting this article in 2018, a number of security issues with leaving phpmyadmin enabled on QNAP. See this article for further security guidance for your QNAP.

    13. We now need to create 3 xml files for use with Kodi
      13.1 Copy and paste the following into a text file and save it as advancedsettings.xml. Change the 3 references to the IP address of to the IP address of your QNAP NAS.
      13.2 Copy and paste the following into a text file and save it as sources.xml. Change the 3 references to the paths of your music, TV shows and Movies to the correct smb paths of the files. (if you choose NFS in step 3 instead of SMB, then ensure you also change the protocol) Feel free to edit the other sources as well, and if you want to add additional sources you can enter them here too:
      <default pathversion="1"></default>
      <default pathversion="1"></default>
      <path pathversion="1">/storage/videos/</path>
      <name>TV Shows</name>
      <path pathversion="1">smb:// series/</path>
      <path pathversion="1">smb://</path>
      <default pathversion="1"></default>
      <path pathversion="1">smb://</path>
      <default pathversion="1"></default>
      <path pathversion="1">/storage/pictures/</path>
      <default pathversion="1"></default>
      <path pathversion="1">/storage/downloads/</path>
      <path pathversion="1">/storage/backup/</path>
      13.3 Copy and paste the following into a text file and save it as passwords.xml, ensure you change the PaSSWordFromStep4 text to the password you choose in step 4 when creating the Kodi user on the QNAP user control panel screen. If you choose a different protocol from SMB remember to change that also.
      <from pathversion="1">smb://</from>
      <to pathversion="1">smb://kodi:[email protected]/</to>
    14. The 3 above saved xml files now need to be copied into your Kodi file system. Now the location of this will depend on what OS your running Kodi on, but they all need to go in the userdata folder. The userdata folder can be found in the following areas:
      Operating system File path
      Android Android/data/org.xbmc.kodi/files/.kodi/userdata/ (see note)
      iOS /private/var/mobile/Library/Preferences/Kodi/userdata/
      Linux ~/.kodi/userdata/
      Mac /Users/<your_user_name>/Library/Application Support/Kodi/userdata/ (see note)
      LibreELEC/OpenELEC /storage/.kodi/userdata/
      Windows Start – type %APPDATA%\kodi\userdata – press <Enter>
      Windows UWP  %LOCALAPPDATA%\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalCache\Roaming\Kodi\

      Source: <- Check this page if you can’t find it incase the location has moved.

    15. Restart your Kodi client
    16. Import the database you created from step 11 if you exported a database, following the same instructions as step 11, but choosing to import the library instead.
    17. If you log back into myPHPadmin you should see that your database has been popularised.
    18. Repeat steps 13-15 for any other additional Kodi clients you have on your network.

Check the kodi.log file in the first instance which should give you an idea as to what the problem is.
If you want support from me, include it in the comments below with as much additional information as possible.

NOTES: Kodi Upgrades the database on each major new Kodi release, so you may want to log into myphpadmin and delete older numbered versions of the database from time to time, you can find out which number is the current DB from your Kodi version by looking here:

Backing Up MySQL Databases on QNAP – Look at this thread on the QNAP support forums on how to setup a backup of your MySQL databases. Don’t be put off by the text here, follow the instructions and it’s very easy to setup.

Leave a Response

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

14 thoughts on “How to setup Kodi database on a QNAP NAS.”

  • Hi,
    First thank you for this clear tutorial. I need your help to have this working. What are the settings that are necessary for Kodi to match the above process and have this working?

    1. Hi,

      Sorry, I don’t fully understand your question, but I’ll try and answer what I think you’re asking. In terms of Kodi settings, you need to change nothing. When Kodi loads it will check for an advancedsettings.xml file as well as the others, once it knows these files exist then it will automatically use the settings you’ve entered into them. There’s nothing to change on the KODI settings screen itself.

      I probably should have linked to this page in the post itself, it may help:

  • Thank you very much for this write-up!

    I have been wanting to do this for a long time, but I got lost trying to follow other guides online, I’m glad I finally found this

  • Hi there,
    First of all I’d like to thank you for this excellent guide. I have never had any experience with mySQL and yet most of the steps went through perfectly.
    I have had 2 issues:
    1. In step 11 of your guide I got an error “# 1396 – Operation CREATE USER failed for ‘Kodi’@’%’ (I can send you a screen shot if you send me a mail). I am not sure whether that may be the reason for issue number 2…
    2. I restarted Kodi after all the changes and all the library is accessible but for some strange reason there are no thumnails at all for any movie at all. not just those that were in my library but also those that come from Addon who just shows you latest movie releases etc… all the thumnails are gone.
    3. Question: You didn’t give instructions to change the settings for the mediasources.xml even though it contains a path to the main video libray… is that on purpose?…
    thanks in advance for answering my questions and issues and for your help in getting me set up with my Kodi and my new QNap NAS.

    1. One more issue I discovered:
      When in Kodi I try to access the various video libraries I defined in the process, it doesn’t let me and gives me an error: “couldn’t connect to the server”. …

      1. Post your kodi.log file.

        I’m guessing it’s probably going to be incorrect password, or wrong IP address in the advancedsettings.xml file. Try logging into the phpmyadmin page with the password you set for the kodi account in step 11, and make sure you’re using the same username and password in your advancedsettings.xml, as well as pointing to the right IP address.

        Also since I wrote this article a number of security issues with QNAPs have arisen and the advised guidance is to turn off phpmyadmin until you actually need it, so once everything is working, just turn it off in the app center but keep it installed. If you don’t have your QNAP exposed to the internet this won’t be an issue. I’ll edit the guide to highlight this also.

        1. thanks for the quick reply.
          I did double check the issue of the IP and password.
          I can’t really figure out from the kodi.log what the issue is.
          how do I post the log file? I don’t see an option for that here.
          I tried to copy/paste it here in the comment but the system refused to post my comment because it was too long.

  • Excellent work – thank you from the QNAP community.
    I have a specific question regarding the XBMC app the was supported on QNAP. I’d like to get a look at the watch/unwatched database for that, but Kodi/XBMC is now not installed, as it disappeared

    1. I believe Kodi is no longer available via official QNAP app store as there was a legal issue regarding codecs. You can get it back via 3rd party app stores such as

  • Hello,

    Thank you so much for taking time to put together this nice tutorial.

    I can’t seem to get it working. I am trying on a Windows 10 computer then I will move on to the two Firesticks.

    When I enabled the Web Server, I can’t set the HTTPS connection to 443. It seems that on my QNAP that is already in use. It is currently set at port 8081. Is this an issue?

    I exported the database in a single file with no issues. However, when I import it, I see no activity. I tried importing the database stored on the Windows 10 machine and with the database stored on the QNAP. Same results, nothing happens.

    I am not getting a log file in Kodi. There just isn’t one. I believe that means there is no activity?

    Kodi loads fast so I believe that the paths to the Video and TV Show files are correct. I am confident the user is correct because I can only see the Public and Multimedia directories on the QNAP. Other directories it asks for a password.

    I don’t know where to go from here. Any ideas?



    1. Hi Randy,

      The HTTP or HTTPS port number shouldn’t matter. It’s only used when connecting to MyPHPAdmin and the link to open that URL in step 9 should automatically get populated by the QNAP when clicking the link to open MyPHPAdmin

      Something is obviously not right with your advancedsettings.xml file. First see if the databases even got created on the QNAP my logging into myPHPAdmin.

      If not then go over your settings file and make sure they are all pointing at the right IP addresses, ports for the DB, right username and passwords and also pointing at the right path for your media.

      On Windows the log file should be located at either %APPDATA%\Kodi\kodi.log if you installed the desktop verson from the Kodi website, or it will be at %LOCALAPPDATA%\Packages\XBMCFoundation.Kodi_4n2hpmxwrvr6p\LocalCache\Roaming\Kodi\kodi.log if you installed it from the Windows App Store.

      1. I got it it working this morning! I am so excited!

        I think it had something to do with the user in PHP.

        Thanks a bunch!