[mythtv-users] database access

Nick Morrott knowledgejunkie at gmail.com
Thu Mar 5 04:47:19 UTC 2009


On 05/03/2009, backuppc at sundquist.imapmail.org
<backuppc at sundquist.imapmail.org> wrote:
> Ian wrote:
>
>  > > mrrooster wrote:
>  > >
>  > > > Or just omit the password and it will ask you for it on the command
>  > > line...
>  > > >
>  > > > ian[at]pvr:~$ mysql -u mythtv -p mythconverg
>  > > > Enter password:
>  > >
>  > > That worked for me and I got into the database.
>  > >
>  > [snip]
>  >
>  > Does it work if you do:
>  >
>  > mysql -u mythtv -p -h localhost mythconverg
>  >
>  > ie, specify localhost on the command line. You could be connecting through a
>  > local unix socket by default?
>
>
> That works, but so does the mrrooster's suggestion.
>
>  But though I can log in either way on the command line, I can't get
>  nuvexport and other scripts calling MythTV.pm to log into the database
>  to work.
>
>  Note, I have found the same problem with many other scripts that try to
>  log into the database, including optimize_mythdb.pl and even mythweb.
>
>  These are the lines of /usr/share/perl5/MythTV.pm where all these
>  scripts try to log into the database:
>
>     # Connect to the database
>         $self->{'dbh'} =
>         DBI->connect("dbi:mysql:database=$self->{'db_name'}:host=$self->{'db_host'};port=$self->{'db_port'}",
>                                       $self->{'db_user'},
>                                       $self->{'db_pass'})
>             or die "Cannot connect to database: $!\n\n";
>
>  I don't know perl at all.  Is there anyway I can get the perl module to
>  print out the variable values before it tries connecting so I can see
>  what it is using?
>
>  Well, actually, I guess don't need to, it tells me in the error message:
>
>
>  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 337
>  Cannot connect to database:
>
>
> So it is trying to connect through "localhost"
>
>  What about the port number?  3306 is the standard port for mysql to
>  listen on, and it appears to be open:
>
>  user at mythtv:~$ netstat -na | grep 3306
>  tcp        0      0 127.0.0.1:3306          0.0.0.0:*
>  LISTEN
>
>  This is driving me nuts and significantly cuts the value of my mythtv
>  system, although it still goes on great recording and playing back
>  shows.

Log in to MySQL as the root user and connect to the mysql database:

$ mysql -u root -p mysql

First, see which host/user combos exist for user 'mythtv':

mysql> SELECT `Host`,`User`,`Password` FROM `user` WHERE `User` = 'mythtv';

Check to see if the password hashes are the same for all occurences of
the mythtv user, and that you have any entry for localhost.

Now show the users and hosts that are allowed to use the MythTV database:

mysql> SELECT `Host`,`User` FROM `db` WHERE `Db` = 'mythconverg';

Again, ensure you have an entry for localhost.

I'm guessing that either you don't have privileges to connect from
localhost as MySQL user 'mythtv' to the mythconverg database, or that
the password for the user/host combo is not correct.

You might also check your my.cnf file to see if the MySQL server is
bound to a particular hostname/IP.

Nick

-- 
Nick Morrott

MythTV Official wiki:
http://mythtv.org/wiki/
MythTV users list archive:
http://www.gossamer-threads.com/lists/mythtv/users

"An investment in knowledge always pays the best interest." - Benjamin Franklin


More information about the mythtv-users mailing list