DBI connect failed: Access denied for user 'mythtv'@'localhost'

Bug #1012376 reported by danstowell
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
mythexport (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Hi -

Mythexport (on mythbuntu 12.04) fails to connect to the mysql database, for some reason I cannot work out. The ~/.mythtv/config.xml is set up correctly (mythtv itself works fine), and I can successfully browse the database in phpMyAdmin by using the same authentication credentials. Yet when I do "sudo /etc/init.d/mythexport start", this is the kind of thing that appears in /var/log/mythtv/mythexport.log:

-------------
June 12 21:22:50 dan-mythbox /usr/bin/mythexport-daemon[5643]: Starting Processing: 1339532570
DBI connect('database=mythconverg:host=localhost;port=3306','mythtv',...) failed: Access denied for user 'mythtv'@'localhost' (using password: YES) at /usr/share/perl5/MythTV.pm line 351
June 12 21:22:50 dan-mythbox /usr/bin/mythexport-daemon[5643]: Can't connect to MythTV: Cannot connect to database:
 at line 88 in /usr/bin/mythexport-daemon
June 12 21:22:50 dan-mythbox /usr/bin/mythexport-daemon[5643]: Sleeping 5 seconds... hostname dan-mythbox, myth->dbh at line 89 in /usr/bin/mythexport-daemon
DBI connect('database=mythconverg:host=localhost;port=3306','mythtv',...) failed: Access denied for user 'mythtv'@'localhost' (using password: YES) at /usr/share/perl5/MythTV.pm line 351
June 12 21:22:55 dan-mythbox /usr/bin/mythexport-daemon[5643]: Can't connect to MythTV: Cannot connect to database:
 at line 88 in /usr/bin/mythexport-daemon
June 12 21:22:55 dan-mythbox /usr/bin/mythexport-daemon[5643]: Sleeping 5 seconds... hostname dan-mythbox, myth->dbh at line 89 in /usr/bin/mythexport-daemon
--------------

I made a test script based on the mythexport code, as follows:

#!/usr/bin/perl

use strict;
use POSIX qw(setsid);
use DBI;
use DBD::mysql;
use Config::Simple;
use MythTV;
use Proc::Daemon;
use Proc::PID::File;
use Log::Dispatch;
use Log::Dispatch::File;
use Date::Format;
use File::Spec;
use File::Copy;
use XML::Writer;
use IO::File;

use lib '/usr/share/mythexport';
use lib '/usr/share/mythexport/configs';

print "Dan's test script\n";

our $HOSTNAME = `hostname`;
chomp $HOSTNAME;

my $connect = undef;
my $myth = undef;

my $tries = 5;
while ($connect == undef && --$tries > 0) {
    eval {
        $myth = new MythTV();
        # connect to database
        $connect = $myth->{'dbh'};
        1;
    } or do {
        logerror("Can't connect to MythTV: $@");
        logdebug("Sleeping 5 seconds... hostname $HOSTNAME, myth->dbh ");
        sleep(5);
    };
}
if ($connect == undef) {
    die "Couldn't connect to MythTV.";
}
-------------------------

This script has no problems connecting (it prints out "Dan's test script" and nothing else). So why does mythexport choke? It seems mysterious! Any tips please?

Revision history for this message
danstowell (danstowell) wrote :

OK, here's the solution to this problem: the config file ~/.mythtv/config.xml was NOT correct because it was in the wrong user's home directory. When I put it in the right place I got further.

So here's my request:

     PLEASE POST MORE INFORMATIVE LOGGING INFORMATION!

    (If the config file can't be found, the daemon should say so)

Thanks
Dan

Changed in mythexport (Ubuntu):
status: New → Invalid
Revision history for this message
dailyglen (dailyglen) wrote :

Hi, I had the same problem. Thanks for the fix...and yes, I wish there was a better error message. I don't think I would have figured this out by myself.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.