(2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
jjthomas
Newcomer
Posts: 12
Joined: Sun Jul 19, 2015 11:53 am
United States of America

(2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by jjthomas » Mon Jan 15, 2018 10:53 am

Welcome to 2018?

I am running MythTV on Centos 7.4.1708, a fresh installation. I installed MythTV using the @nux-destop.

I'm able to connect to the MythTV database via the command line. I have one config.xml which is linked to /etc/mythtv/config.xml. I've googled, searched and I find multiple instances of this error, but none of the solutions work. In the past, I've been able to get this to work by beating solution into the keyboard, until it works. I would prefer to come up with a concrete solution. A solution that puts this error to rest, once and for all.

I have done multiple installations of MythTV and I always run into this error. Be it FreeBSD, Slackware, ubuntu, Debian, Fedora and now CentOS.

All I get from the logs is:

Code: Select all

2018-01-15 02:02:55.803185 E [2842/2842] CoreContext mythdbcon.cpp:242 (OpenDatabase) - [DBManager0] Unable to connect to database!
2018-01-15 02:02:55.803251 E [2842/2842] CoreContext mythdbcon.cpp:243 (OpenDatabase) - Driver error was [1/1045]:
QMYSQL: Unable to connect
Database error was:
Access denied for user 'mythtv'@'localhost' (using password: YES)
My config.xml:

Code: Select all

[jjthomas@anthem ~]$ cat /etc/mythtv/config.xml 
<Configuration>
  <LocalHostName>my-unique-identifier-goes-here</LocalHostName>
  <Database>
    <PingHost>1</PingHost>
    <Host>anthem.027esc.net</Host>
    <UserName>mythtv</UserName>
    <Password>AWvsUQbN7a85SjK2</Password>
    <DatabaseName>mythconverg</DatabaseName>
    <Port>3306</Port>
  </Database>
  <WakeOnLAN>
    <Enabled>0</Enabled>
    <SQLReconnectWaitTime>0</SQLReconnectWaitTime>
    <SQLConnectRetry>5</SQLConnectRetry>
    <Command>echo 'WOLsqlServerCommand not set'</Command>
  </WakeOnLAN>
</Configuration>
Find config.xml:

Code: Select all

[root@anthem ~]# find / -name 'config.xml'
/etc/mythtv/config.xml
/home/jjthomas/.mythtv/config.xml

[root@anthem ~]# ls -l /etc/mythtv/config.xml 
lrwxrwxrwx. 1 root root 33 Jan 15 01:31 /etc/mythtv/config.xml -> /home/jjthomas/.mythtv/config.xml
Connecting to MySQL (MariaDB), directly

Code: Select all

[root@anthem ~]# mysql -u mythtv -pAWvsUQbN7a85SjK2
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit
Bye
By all rights, this should work.

Help?

TIA

-JJ

PhilB
Senior
Posts: 223
Joined: Sun May 11, 2014 6:23 pm
Great Britain

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by PhilB » Mon Jan 15, 2018 11:44 am

This may be at a slight tangent but a common pitfall is that a normal combined frontend/backend installation needs two copies of that file:
One for the backend running under user mythtv placed in /home/mythtv/.mythtv/config.xml
One for the frontend running under <you> placed in /home/<you>/.mythtv/config.xml
One or other of them may be a link to /etc/mythtv/config.xml

For the frontend to work it needs a valid config.xml.
Regards
Phil

jjthomas
Newcomer
Posts: 12
Joined: Sun Jul 19, 2015 11:53 am
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by jjthomas » Mon Jan 15, 2018 7:17 pm

Hello,

I added .mythtv/config.xml to every directory I could think of. Still not working.

Here are my locations of the file config.xml, all the files are identical:

Code: Select all

[root@anthem .mythtv]# find / -iname "config.xml"
/usr/share/doc/mythtv-docs-29.0/contrib/config_files/config.xml
/etc/mythtv/config.xml
/root/.mythtv/config.xml
/var/lib/mythtv/.mythtv/config.xml
/home/mythtv/.mythtv/config.xml
/home/jjthomas/.mythtv/config.xml
MythTV user:

Code: Select all

mythtv:x:989:981:mythbackend user:/var/lib/mythtv:/sbin/nologin
I went a little further in to the logs and found that MythTV complains that is cannot find the host name:

Code: Select all

2018-01-15 10:58:04.554092 E [16660/16660] CoreContext mythdbparams.cpp:39 (IsValid) - DBHostName is not set in config.xml
2018-01-15 10:58:04.554126 E [16660/16660] CoreContext mythdbparams.cpp:39 (IsValid) - DBHostName is not set in config.xml
2018-01-15 10:58:04.554174 N [16660/16660] CoreContext mythcontext.cpp:599 (LoadDatabaseSettings) - Empty LocalHostName.
2018-01-15 10:58:04.554189 I [16660/16660] CoreContext mythcontext.cpp:607 (LoadDatabaseSettings) - Using localhost value of anthem.027esc.net
2018-01-15 10:58:04.554307 I [16660/16660] CoreContext mythcontext.cpp:849 (TestDBconnection) - Start up testing connections. DB localhost, BE , attempt 0, status dbAwake
2018-01-15 10:58:04.656580 I [16660/16670] LogForward loggingserver.cpp:146 (FileLogger) - Added logging to /var/log/mythtv/mythbackend.20180115185804.16660.log
2018-01-15 10:58:05.579113 E [16660/16660] CoreContext mythdbcon.cpp:242 (OpenDatabase) - [DBManager0] Unable to connect to database!
2018-01-15 10:58:05.579188 E [16660/16660] CoreContext mythdbcon.cpp:243 (OpenDatabase) - Driver error was [1/1045]:
QMYSQL: Unable to connect
Database error was:
Access denied for user 'mythtv'@'localhost' (using password: YES)
Access to the database from the command line works just fine:

Code: Select all

mysql -u mythtv -h anthem.027esc.net -pAWvsUQbN7a85SjK2 
I forgot to add that I am running MythTV version 29.
uname -a:Linux anthem.027esc.net 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Jan 4 01:06:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Is there a way to find out, for sure, where MythTV is looking for config.xml. Would it help to add my hostname somewhere?

-JJ

User avatar
bill6502
Developer
Posts: 1085
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by bill6502 » Mon Jan 15, 2018 9:16 pm

Hi,

Look for a line similar to this in your logs (both frontend and backend will
have it.):

Code: Select all

2018-01-12 11:08:10.785157 N [2335/2335] thread_unknown mythdirs.cpp:205 (InitializeMythDirs) - Using configuration directory = /home/mythtv/.mythtv
Also, this Wiki: https://www.mythtv.org/wiki/Config.xml#Troubleshooting

jjthomas
Newcomer
Posts: 12
Joined: Sun Jul 19, 2015 11:53 am
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by jjthomas » Tue Jan 16, 2018 12:50 am

I see Read conf dir = /etc/mythtv Using configuration directory = /etc/mythtv

For grins and giggles I put config.xml in /etc/mtyhtv/.mythtv. No help.

Code: Select all

[root@anthem ~]# grep -rnw '/var/log/mythtv/' -e mythdirs
/var/log/mythtv/mythbackend.20180115183154.14873.log:15:2018-01-15 10:31:54.282683 N [14873/14873] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115183154.14873.log:16:2018-01-15 10:31:54.282741 N [14873/14873] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115183154.14873.log:17:2018-01-15 10:31:54.282746 N [14873/14873] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115093429.13010.log:15:2018-01-15 01:34:29.513314 N [13010/13010] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115093429.13010.log:16:2018-01-15 01:34:29.513379 N [13010/13010] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115093429.13010.log:17:2018-01-15 01:34:29.513385 N [13010/13010] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115185804.16660.log:15:2018-01-15 10:58:04.553187 N [16660/16660] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115185804.16660.log:16:2018-01-15 10:58:04.553258 N [16660/16660] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115185804.16660.log:17:2018-01-15 10:58:04.553263 N [16660/16660] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115184113.15487.log:15:2018-01-15 10:41:13.264492 N [15487/15487] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115184113.15487.log:16:2018-01-15 10:41:13.264548 N [15487/15487] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115184113.15487.log:17:2018-01-15 10:41:13.264553 N [15487/15487] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115105415.5109.log:15:2018-01-15 02:54:15.351469 N [5109/5109] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115105415.5109.log:16:2018-01-15 02:54:15.351539 N [5109/5109] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115105415.5109.log:17:2018-01-15 02:54:15.351544 N [5109/5109] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115100254.2842.log:15:2018-01-15 02:02:54.759882 N [2842/2842] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115100254.2842.log:16:2018-01-15 02:02:54.759946 N [2842/2842] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115100254.2842.log:17:2018-01-15 02:02:54.759951 N [2842/2842] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115093423.12981.log:15:2018-01-15 01:34:23.924118 N [12981/12981] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115093423.12981.log:16:2018-01-15 01:34:23.924173 N [12981/12981] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115093423.12981.log:17:2018-01-15 01:34:23.924177 N [12981/12981] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115093153.12870.log:15:2018-01-15 01:31:53.241334 N [12870/12870] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115093153.12870.log:16:2018-01-15 01:31:53.241389 N [12870/12870] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115093153.12870.log:17:2018-01-15 01:31:53.241393 N [12870/12870] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115094727.13489.log:15:2018-01-15 01:47:27.897006 N [13489/13489] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115094727.13489.log:16:2018-01-15 01:47:27.897062 N [13489/13489] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115094727.13489.log:17:2018-01-15 01:47:27.897066 N [13489/13489] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115182932.14689.log:15:2018-01-15 10:29:32.520592 N [14689/14689] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115182932.14689.log:16:2018-01-15 10:29:32.520654 N [14689/14689] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115182932.14689.log:17:2018-01-15 10:29:32.520658 N [14689/14689] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115093503.13033.log:15:2018-01-15 01:35:03.180615 N [13033/13033] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115093503.13033.log:16:2018-01-15 01:35:03.180679 N [13033/13033] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115093503.13033.log:17:2018-01-15 01:35:03.180685 N [13033/13033] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115092935.12783.log:15:2018-01-15 01:29:35.055930 N [12783/12783] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115092935.12783.log:16:2018-01-15 01:29:35.055991 N [12783/12783] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115092935.12783.log:17:2018-01-15 01:29:35.055995 N [12783/12783] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv
/var/log/mythtv/mythbackend.20180115104656.4630.log:15:2018-01-15 02:46:56.673087 N [4630/4630] thread_unknown mythdirs.cpp:33 (InitializeMythDirs) - Read conf dir = /etc/mythtv
/var/log/mythtv/mythbackend.20180115104656.4630.log:16:2018-01-15 02:46:56.673178 N [4630/4630] thread_unknown mythdirs.cpp:195 (InitializeMythDirs) - Using runtime prefix = /usr
/var/log/mythtv/mythbackend.20180115104656.4630.log:17:2018-01-15 02:46:56.673185 N [4630/4630] thread_unknown mythdirs.cpp:197 (InitializeMythDirs) - Using configuration directory = /etc/mythtv

jjthomas
Newcomer
Posts: 12
Joined: Sun Jul 19, 2015 11:53 am
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by jjthomas » Tue Jan 16, 2018 1:23 am

I took a look at https://www.mythtv.org/wiki/Config.xml#Troubleshooting , everything seems to be okay.

Relevant information in /usr/lib/systemd/system/mythbackend.service:

Code: Select all

[root@anthem ~]# grep -v '^#' /usr/lib/systemd/system/mythbackend.service
[Unit]
Description=MythTV backend service
After=network-online.target mariadb.service mysqld.service time-sync.target

[Service]
Type=simple
Environment=MYTHCONFDIR=/etc/mythtv
User=mythtv
ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv

[Install]
WantedBy=multi-user.target
I've never debugged a program, but if you can give me instructions, I'll give it a shot.

BTW running /usr/bin/mythbackend as root works fine. and when
I gave mythtv a login script /bin/bash and it runs fine as mythtv user

Thank you for helping, i really want to get this working.

-JJ

User avatar
bill6502
Developer
Posts: 1085
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by bill6502 » Tue Jan 16, 2018 1:32 am

.mythtv is the configuration directory typically used in ~mythtv or ~.
Your system is using /etc/mythtv, so put config.xml directly under
it.

Note the line in the backend service file: Environment=MYTHCONFDIR=/etc/mythtv,
that's why /etc/mythtv is showing up in the log.

jjthomas
Newcomer
Posts: 12
Joined: Sun Jul 19, 2015 11:53 am
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by jjthomas » Tue Jan 16, 2018 1:50 am

It is, I went ahead and copied my users config.xml to /etc/mythtv.

Code: Select all

[root@anthem ~]# ls -l /etc/mythtv
total 4
-rw-r--r--. 1 root root 645 Jan 15 17:35 config.xml

Code: Select all

<Configuration>
  <LocalHostName>my-unique-identifier-goes-here</LocalHostName>
  <Database>
    <PingHost>1</PingHost>
    <Host>anthem.027esc.net</Host>
    <UserName>mythtv</UserName>
    <Password>AWvsUQbN7a85SjK2</Password>
    <DatabaseName>mythconverg</DatabaseName>
    <Port>3306</Port>
  </Database>
  <WakeOnLAN>
    <Enabled>0</Enabled>
    <SQLReconnectWaitTime>0</SQLReconnectWaitTime>
    <SQLConnectRetry>5</SQLConnectRetry>
    <Command>echo 'WOLsqlServerCommand not set'</Command>
  </WakeOnLAN>
  <UPnP>
    <UDN>
      <MediaRenderer>8c8ef326-27be-48e4-90a8-cfde98d1131e</MediaRenderer>
    </UDN>
  </UPnP>
</Configuration>
and crap now it works...

jjthomas
Newcomer
Posts: 12
Joined: Sun Jul 19, 2015 11:53 am
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by jjthomas » Tue Jan 16, 2018 3:40 am

Okay, here is what I found:

MythTV does not follow the link from /etc/mythtv to /home/jjthomas/.mythtv/config.xml
The solution is to copy the file directly to /etc/mythtv/config.xml

It seemed that things changed when i changed /etc/passwd for the mythtv user from /sbin/nologin to /bin/bash
I also added config.xml to /var/lib/mythtv/.mythtv I have since change the /etc/passwd back to /sbin/nologin and
removed /var/lib/mythtv/.mythtv/config.xml.

And I had to make sure mythbackend starts at bootup via: systemctl enable mythbackend.service
and I had to turn off the firewall. I'm using a HDHomeRun tuner.

I hope this will help the next person,or myself when I have to reinstall. :)

Thank you for the help. And thank you for all your work on MythTV.

-JJ

User avatar
bill6502
Developer
Posts: 1085
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by bill6502 » Tue Jan 16, 2018 3:38 pm

To be clear, the Environment=MYTHCONFDIR=/etc/mythtv line in the
backend service is pointing directly to /etc/mythtv. The HOME directory
developed from the mythtv user isn't in play as MYTHCONFIDIR overrides
it.

vidtek
Newcomer
Posts: 5
Joined: Wed Aug 05, 2015 4:47 pm
Great Britain

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by vidtek » Thu Aug 09, 2018 4:10 pm

The service name has variants, if this: systemctl enable mythbackend.service
doesn't work use this: systemctl enable mythtv-backend.service

Tony

User avatar
bill6502
Developer
Posts: 1085
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: (2018) Access denied for user 'mythtv'@'localhost' (using password: YES)

Post by bill6502 » Thu Aug 09, 2018 4:56 pm

systemctl list-units | grep myth

or systemctl status myth<then the tab key>

Will help.

Post Reply