[mythtvnz] Mythfrontend fails to connect to database

Stephen Worthington stephen_agent at jsw.gen.nz
Wed Jul 17 03:56:48 BST 2013


On Wed, 17 Jul 2013 10:06:56 +1200, you wrote:

>
>
>I have been getting FE start failures,when booting the system, where the  
>desktop ends up at a Language selection screen.
>To get out of that I hit esc which takes me to a Database setup screen  
>with a message that mythtv failed to connect to the local database ,was  
>the address correct? etc.Hitting esc again takes me to the xfce desktop  
>and the front end automatically restarts.
>The system is a combined BE/FE and this failure does not always occur.The  
>BE never fails to start and record any scheduled programmes.
>This hasn't been much of a hassle ,as hitting esc restarts the FE.
>
>in FE log I get this:
>
>Jul 17 09:16:13 myth mythlogserver: mythfrontend[1494]: N CoreContext  
>mythcontext.cpp:493 (LoadDatabaseSettings) Empty LocalHostName.
>Jul 17 09:16:13 myth mythlogserver: mythfrontend[1494]: I CoreContext  
>mythcontext.cpp:501 (LoadDatabaseSettings) Using localhost value of myth
>Jul 17 09:16:13 myth mythlogserver: mythfrontend[1494]: I Logger  
>logging.cpp:306 (run) Added logging to the console
>Jul 17 09:16:13 myth mythlogserver: mythfrontend[1494]: E CoreContext  
>mythdbcon.cpp:216 (OpenDatabase) Unable to connect to database!
>Jul 17 09:16:13 myth mythlogserver: mythfrontend[1494]: E CoreContext  
>mythdbcon.cpp:217 (OpenDatabase) Driver error was [1/2002]:#012QMYSQL:  
>Unable to connect#012Database error was:#012Can't connect to local MySQL  
>server through socket '/var/run/mysqld/mysqld.sock' (2)
>
>I think it might be timing problem but am not sure.
>
>Paul

This is almost certainly a network timing problem, caused by using the
real external IP address of your box instead of localhost.  I fixed
this by adjusting upstart's /etc/init/mythtv-backend.conf file to wait
for the ethernet interface to be up instead of just localhost.  The
Mythbuntu devs have attempted to fix this problem already, and their
fix (the current "start on" line) works if you have simple networking
where you only have one localhost and one ethernet interface on the
box.  This is what they have in 12.04:

start on (local-filesystems and net-device-up IFACE!=lo and started
udev-finish)

But if, like me, you have more than one other network interface (I
have two ethernet cards and a bridged interface for using with VPNs),
then that version does not work and you still need to customise it.
What happens is that one of your other network interfaces comes up
before the one that mythbackend runs on does, and that satisfies the
"net-device-up IFACE!=lo" condition, allowing mythbackend to start. In
the worst case (what I was getting occasionally) you can actually have
mythbackend start before it should and shut down again due to not
having a network interface.  More usually, it starts and does
eventually find the network interface once it comes up, but
mythfrontend does not see mythbackend in time and thinks it does not
have a connection.

To fix this, comment out the current "start on" line and replace it
with this (if you mythbackend connects on eth0):

start on (local-filesystems and net-device-up IFACE=eth0 and started
udev-finish)

I need to use this:

start on (local-filesystems and net-device-up IFACE=eth0 and
net-device-up IFACE=br0 and net-device-up IFACE=eth1 and started
udev-finish)



More information about the mythtvnz mailing list