Frontend Can't Connect To Database

For discussion of topics specific to MythTV on linux
Post Reply
kbocek
Senior
Posts: 201
Joined: Mon Jul 20, 2015 4:42 pm
United States of America

Frontend Can't Connect To Database

Post by kbocek »

With the hot weather here in CA my router took a dirt nap and I'm re-configuring my network with an unused wireless router. My database and mythtv-backend are on two different hosts. Both frontends can see both servers just fine and vice-versa. I have tried setting config.xml on the frontends using a hostname (which resolves from the command line) and IP address. I have checked mysql on the database server and mythtv-backend on the myth server. This was all working before the old router died.

Does anyone have any ideas?
User avatar
bill6502
Developer
Posts: 2299
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Frontend Can't Connect To Database

Post by bill6502 »

Remove mythtv from the picture and try this (if it doesn't work, then the frontend won't):
mysql --user=mythtv --host=<your DB hostname here> --password mythconverg
The user/host/password/DB name are from the config.xml used when starting the FE.
kbocek
Senior
Posts: 201
Joined: Mon Jul 20, 2015 4:42 pm
United States of America

Re: Frontend Can't Connect To Database

Post by kbocek »

Well now I'm confused. From the command line

Code: Select all

#mysql -u mythtv -h amber -p
Works fine. I am able to use mythconverg and run a query. But updating /home/mythtv/.mythtv/config.xml to

Code: Select all

<Configuration>
  <Database>
    <PingHost>1</PingHost>
    <Host>amber</Host>
    <UserName>mythtv</UserName>
    <Password>mythconverg</Password>
    <DatabaseName>mythconverg</DatabaseName>
    <Port>3306</Port>
And the frontend still won't connect. I went into the setup screen to confirm settings.

Any ideas?
blm-ubunet
Senior
Posts: 265
Joined: Sun Jun 15, 2014 1:08 am
Cambodia

Re: Frontend Can't Connect To Database

Post by blm-ubunet »

amber is likely resolved in local hosts file..
But AFAIK for config.xml file..
Host can only be localhost or an IP address .
Can not use a DNS resolvable name.
User avatar
bill6502
Developer
Posts: 2299
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Frontend Can't Connect To Database

Post by bill6502 »

I use host names (known to /etc/hosts) OK.

@kbocek, let's see the FE log from startup to failure. pastebin.com is fine
as long as no password is required.
blm-ubunet
Senior
Posts: 265
Joined: Sun Jun 15, 2014 1:08 am
Cambodia

Re: Frontend Can't Connect To Database

Post by blm-ubunet »

Did not know a name would work there. The wiki does not agree??

But he said he's using separate PC for DB & MFE so he needs the same hosts file content in both files or needs a DNS or resolver.
User avatar
bill6502
Developer
Posts: 2299
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Frontend Can't Connect To Database

Post by bill6502 »

@blm-ubunet, please mention the Wiki and I'll fix it.

Agreed, amber should resolve to the same IP everywhere. We'll see where the failure is in the log.
kbocek
Senior
Posts: 201
Joined: Mon Jul 20, 2015 4:42 pm
United States of America

Re: Frontend Can't Connect To Database

Post by kbocek »

This seems to be a name resolution issue. With my now deceased router I was doing local DNS and had a pseudo-domain ".pvt" for all my LAN addresses. I've had to fall back on a wireless router to get the house net access. But the DNS server went away and along with it ".pvt". I've gone through all the hosts and setup static name resolution through /etc/hosts.

The two server hosts are amber (mysql) and myth (mythtv-backend and mythweb). Mythweb is now saying

Code: Select all

Unable to connect to the master backend at 10.0.2.2:6543.
Is it running?
That is the correct address for myth. Checking the status of mythbackend:

Code: Select all

$ sudo systemctl status mythtv-backend
● mythtv-backend.service - MythTV Backend
   Loaded: loaded (/lib/systemd/system/mythtv-backend.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2022-09-08 10:21:36 PDT; 24s ago
     Docs: https://www.mythtv.org/wiki/Mythbackend
 Main PID: 3093 (mythbackend)
    Tasks: 6 (limit: 2299)
   CGroup: /system.slice/mythtv-backend.service
           └─3093 /usr/bin/mythbackend --quiet --syslog local7
Mythbackend runs for a few minutes but then fails with

Code: Select all

Sep  8 10:22:22 myth mythbackend: mythbackend[3093]: I CoreContext mythcontext.cpp:852 (TestDBconnection) Start up testing connections. DB amber.pvt, BE , attempt 10, status dbAwake
Sep  8 10:22:27 myth mythbackend: mythbackend[3093]: I CoreContext mythcontext.cpp:971 (TestDBconnection) Start up failure. host amber.pvt, status dbAwakeFail
Sep  8 10:22:28 myth mythbackend: mythbackend[3093]: C CoreContext main.cpp:132 (main) Failed to init MythContext.
Does that mean it can't contact the database? If so it sounds like a permissions error on the database.
kbocek
Senior
Posts: 201
Joined: Mon Jul 20, 2015 4:42 pm
United States of America

Re: Frontend Can't Connect To Database

Post by kbocek »

Finally found it! /etc/mythtv/config.xml on myth still had "amber.pvt". Changed that to "amber" and corrected the password and it looks like all is good! Yay! What a PITA.

Thank you all for your suggestions. Even though you didn't know my exact solution, all your suggestions helped guide my debugging process.
kbocek
Senior
Posts: 201
Joined: Mon Jul 20, 2015 4:42 pm
United States of America

Re: Frontend Can't Connect To Database

Post by kbocek »

Now that I think about it I think I could have just added all my ".pvt" host names to the hosts file and everything would have just worked. Ugh. Hind-sight is 20-20.
Post Reply