Win Using MySQL for Central database safely when Mediaportal is also installed
#1
I have Mediaportal installed, which uses a MySQL database and I want to setup a central database for XBMC, running on this PC and a RPi, as well.

I'm just nervous about following the guides like this http://lifehacker.com/5634515/how-to-syn...-the-house or this http://wiki.xbmc.org/index.php?title=HOW...ab=Windows as they're obviously not designed to take my circumstances into consideration and I'm worried I'll mess up the Mediaportal database.

I see the first commands to be run are Create USER followed by Create Database which suggests a separate database will be used for XBMC but before that, when installing MySQL it talks about selecting a password for the database, which is a bit confusing if it hasn't been created yet and suggests that there's some global settings that will apply to both the MP and XBMC databases.
Reply
#2
First, don't use the lifehacker guide as this is out of date. The guide on the wiki is for frodo.

As to the databases, you've already got mySQL running so you should not be asked to enter a password. You just need to create a new user (xbmc), give that user a password and then grant access to the dbs for that user. The guides suggest granting xbmc access to all dbs
Code:
GRANT ALL ON *.* TO 'xbmc';
so you may not want to do that as user xbmc will have access to the mediaportal dbs.

Instead follow the instructions at the end of the wiki page which will prevent user xbmc having access to the mediaportal info
Quote:Optional: For a more secure MySQL installation use these 2 commands to grant permission only to databases XBMC uses. This is useful if you plan on using your MySQL server for more than just XBMC, or if you're worried about your internal network being exposed and wanting to lock things down more, etc. If you only use the MySQL server for XBMC and that server has non-critical data on it, then this probably not necessary.
GRANT ALL ON `MyMusic%`.* TO 'xbmc'@'%' IDENTIFIED BY 'xbmc';
GRANT ALL ON `MyVideos%`.* TO 'xbmc'@'%' IDENTIFIED BY 'xbmc';

It will all be fine with that - but of course make sure you backup the existing dbs before you start playing around.
Openelec on ASRock ION 330 / Kodi on Win 7 PC
Reply
#3
Thanks, yeah I just noticed it's dated 2010!

So I've created the user xbmc but I'm not sure how to give it a password. I've also already done the GRANT ALL command, so do you know how to undo that so that I can do the commands to give XBMC more limited access to just it's databases?

I've just noticed on http://wiki.xbmc.org/index.php?title=HOW...ts_of_XBMC it says "DO NOT TRY TO SHARE DATABASES." which is rather confusing as that's the whole point of doing this! I guess it means don't try and share the .db files rather than don't try and use a shared central database.
Reply
#4
yes - the DO NOT SHARE DATABASES is referring to sharing using path substitution. The local sqlite db is not designed for multiple user access.

With regards to the privileges you have granted to xbmc you can use REVOKE to revoke what you have granted http://dev.mysql.com/doc/refman/4.1/en/revoke.html
Openelec on ASRock ION 330 / Kodi on Win 7 PC
Reply
#5
OK, great so I've revoked what I did before and granted the more limited access to xbmc now. I see that the IDENTIFIED BY part of the Create User command is what sets the password as well.

What I still need to do is delete the unneeded xbmc_video and xbmc_music databases. I tried DROP database xbmc_video but that just returns a different prompt where I can't do anything except Ctrl+C to close the command window. I'm also not sure if the user xbmc has access yet as only root is shown next to 127.0.0.1 and localhost. Perhaps the % signifies Any interface/address in which case I guess the other lines are superfluous.

+-----------+------+
| host | user |
+-----------+------+
| % | root |
| % | xbmc |
| 127.0.0.1 | root |
| localhost | |
| localhost | root |
+-----------+------+
5 rows in set (0.00 sec)

mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| argustv |
| mptvdb |
| mymusic32 |
| mysql |
| myvideos75 |
| test |
| xbmc_music |
| xbmc_video |
+--------------------+
9 rows in set (0.00 sec)
Reply
#6
When using the mySQL don't forget to put a ; at the end of the command. It may also be easier to manage the databases using mySQL workbench or HeidiSQL or similar GUI programs.

Although, having the xbmc_music etc there wont do anything other than take up a few bytes on the server.
Openelec on ASRock ION 330 / Kodi on Win 7 PC
Reply
#7
Ah thanks, that's what I was missing.

Nothing to do with that, as it started before I dropped the two unused databases but I still can't access the database with xbmc/xbmc In fact, trying to do so after populating it using root/Mediaportal resulted in it not working (i.e. not being able to access or scrape to it) even after changing back to root/Mediaportal, although it's started working again now.

I needed to start again anyway as I'd originally done it using local paths E:\Media\Movies which mean nothing on the RPi and so it told me all my movies were no longer available, so now I'm scraping using my NFS path NFS://192.168.1.64/Media/Movies.

I wonder if MySQL is case-sensitive as the command given is GRANT ALL ON `MyMusic%`.* TO 'xbmc'@'%' IDENTIFIED BY 'xbmc'; but the database is shown as mymusic32
Reply
#8
Not sure what's happening now but I still can't play anything from the RPi, even after rescraping using the NFS path. I'm not even sure it's using the central database as if I go into Files there's sources shown that shouldn't be but then if I remove all of those, I still get the Library options which I wouldn't normally when using a local database after removing all sources. Actually, on the PC the Music Library has disappeared so it seems I must have removed the actual NFS sources on the RPi (is there any way to prevent this, maybe lock out the Files view so that the sources can't be removed?) which makes it all the more bizarre that the RPi is still showing the Library views (I guess it must have cached the database)

This is my /storage/.xbmc/userdata/advancedsettings.xml

Code:
<advancedsettings>
<cputempcommand>cputemp</cputempcommand>
<gputempcommand>cputemp</gputempcommand>
<showexitbutton>false</showexitbutton>
<destroywindowcontrols>false</destroywindowcontrols>
<useddsfanart>false</useddsfanart>
<fanartheight>540</fanartheight>
<thumbsize>256</thumbsize>
   <network>
        <alwaysforcebuffer>false</alwaysforcebuffer>
        <freememorycachepercent>5</freememorycachepercent>
   </network>
   <gui>
       <algorithmdirtyregions>3</algorithmdirtyregions>      
       <nofliptimeout>0</nofliptimeout>
       <guires>720</guires>
   </gui>
<video>
  <defaultplayer>omxplayer</defaultplayer>
  <defaultdvdplayer>omxplayer</defaultdvdplayer>
</video>
<audio>
  <defaultplayer>omxplayer</defaultplayer>
  <streamsilence>false</streamsilence>
</audio>
<lookandfeel>
  <enablerssfeeds>false</enablerssfeeds>
</lookandfeel>
   <bginfoloadermaxthreads>2</bginfoloadermaxthreads>
   <videodatabase>
        <type>mysql</type>
        <host>192.168.1.64</host>
        <port>3306</port>
        <user>root</user>
        <pass>MediaPortal</pass>
   </videodatabase>
   <musicdatabase>
       <type>mysql</type>
       <host>192.168.1.64</host>
       <port>3306</port>
       <user>root</user>
       <pass>MediaPortal</pass>
   </musicdatabase>
   <videolibrary>
          <importwatchedstate>true</importwatchedstate>
   </videolibrary>
</advancedsettings>

For music files, I see these errors in the log

17:05:59 T:2891969632 ERROR: COMXPlayer::OpenInputStream - error opening [musicdb://4/1101.mp3]
17:05:59 T:2891969632 NOTICE: COMXPlayer::OnExit()
17:05:59 T:2891969632 DEBUG: OMXClock::OMXStop
17:05:59 T:2891969632 NOTICE: COMXPlayer::OnExit() deleting input stream
17:05:59 T:3043123200 ERROR: Playlist Player: skipping unplayable item: 93, path [musicdb://4/1101.mp3]

and for video these

17:13:28 T:3043123200 DEBUG: OnClick called on 'videodb://1/2/111' but file doesn't exist
17:13:31 T:3043123200 DEBUG: OnClick called on 'videodb://1/2/10' but file doesn't exist
Reply
#9
Ack, somehow the MediaPortal part of the database has got messed up and I can't access it via the commandline with the MediaPortal password anymore, nor can I watch LiveTV or scan for channels on the PC. I guess I'll need to start from scratch with a fresh database once I find out how to do that.
Reply

Logout Mark Read Team Forum Stats Members Help
Using MySQL for Central database safely when Mediaportal is also installed0