[mythtv-users] Is there an approved may to remove frontend settings?

Mike Perkins mikep at randomtraveller.org.uk
Sun Feb 2 17:01:21 UTC 2014


On 02/02/14 16:05, R. G. Newbury wrote:
> On 02/02/14 07:18 AM, Anthony Giggins wrote:
>> is there an approved way to remove old frontend hostnames from the database?
>>
>> I've got a mix of old hostnames with a mix of with & without domain names.
>>
>> Happy if someone could point me at the correct tables I have a good
>> understand of SQL.
>
> "Approved"? No. Like any deep spelunking, it can get dangerous.
> So start with a backup of the database, or 2 or 3!
>
> The settings table holds settings for each 'instance' of myth. It sounds like
> you may have entries which actually point to the same box, due to your
> namechanges. And some entries are properly set to NULL. A complete mythtv setup
> puts about 250 settings into the settings table.
>
> As a first step, make sure that your computer has the correct hostname set in
> /etc/hostname (and that 'hostname' on the command line returns the same thing!).
>
> Then look at the settings table.
> mysql> select * from settings;
> and
> mysql> select * from settings [where hostname="correcthostname"];
>
> If you get 750 records and 300 records respectively, you have some work to do!
>
> You may have active entries under the hostname 'localhost' too. So you cannot
> just delete ALL the 'incorrect' settings without checking that there is a
> correct duplicate value entry. Most of the 'localhost' entries can be/should be
> set to your hostname. But don't mess with the 'NULL' entries.
>
> You can use:
> select value, data, count( value) from settings group by value having
> count(value) > 1 ;
> to find duplicate instances of 'value' in settings
> Similar calls will give duplicates in other tables.
>
> Beyond that, the hostname is also a field in the following tables:
>   capturecard
>   displayprofilegroups
>   housekeeping
>   inuseprograms
>   jobqueuea
>   jumppoints
>   keybindings
>   livestream
>   music_playlists
>   profilegroups
>   recordedartwork
>   recordedfile
>   recorded
>   scannerpath
>   storagegroup
>   tvchain
>   weatherscreens
>   weathersourcesettings
>
> Having duplicate hostname rows in most of these tables is innocuous as only the
> 'correct' entries will be in use. You can easily do a 'delete from ... where
> hostname="wrong";' in those tables.
>
> But you will have to check to see if items with the 'wrong' hostname' in the
> recorded* tables are actually visible in 'Watch Recordings'. You may hange those
> entries, and find that you have more recorded shows than you thought!
>
> You *may* want to do backups at intermediate stages and proceed carefully.
>
>
Deleting wrong hostnames may not be the correct solution in some cases. Consider 
your recordings, for example. If you blindly delete rows with bad hostnames from 
'recorded' you could end up with orphaned recordings.

A better solution in this case would be to change the hostname to one that 
matches the host where the recording now exists. This means the system would 
still be able to find it.

This is all reasonably straightforward if you only have one backend, of course. 
Multiple backends will be much harder to resolve.

-- 

Mike Perkins



More information about the mythtv-users mailing list