[solved] mythweb Access denied for user 'mythtv'@'localhost'

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

Moderator: Forum Moderators

Linuxgrrl
Junior
Posts: 67
Joined: Mon Oct 26, 2020 12:46 am
United States of America

[solved] mythweb Access denied for user 'mythtv'@'localhost'

Post by Linuxgrrl »

I have mythtv installed on Linux Mint. I tried connecting via Mythweb for the first time today and I got the above error message. I checked /etc/apache2/sites-enabled/mythweb.conf and it has prepopulated correctly with db_login as mythtv and db_password as my correct mythtv database password in plain text (same one that appears in /.mythtv/config/config.xml). I have not attempted to set up any other passwords.
The wiki seems to indicate Mythweb should "just work" now ... what could be wrong?
Here is some additional info from mysql in case it helps:

Code: Select all

mysql> SHOW GRANTS FOR 'mythtv'@'localhost';

+--------------------------------------------------------------------------+
| Grants for mythtv@localhost                                              |
+--------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `mythtv`@`localhost`                               |
| GRANT CREATE TEMPORARY TABLES ON `mythconverg`.* TO `mythtv`@`localhost` |
+--------------------------------------------------------------------------+
2 rows in set (0.00 sec)
Last edited by Linuxgrrl on Sat Feb 06, 2021 8:34 pm, edited 1 time in total.
gedakc
Junior
Posts: 96
Joined: Fri Jul 18, 2014 1:28 am
Canada

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by gedakc »

For reference I checked the grants on my Raspberry Pi 4 with the MythTV light v31 packages installed I see the following:

Code: Select all

MariaDB [mythconverg]> show grants;
+------------------------------------------------------------------------------------------------------------------------------------------+                                                                      
| Grants for mythtv@localhost                                                                                                              |                                                                      
+------------------------------------------------------------------------------------------------------------------------------------------+                                                                      
| GRANT ALL PRIVILEGES ON *.* TO `mythtv`@`localhost` IDENTIFIED BY PASSWORD '*pwd-editedout' WITH GRANT OPTION |                                                                      
+------------------------------------------------------------------------------------------------------------------------------------------+
Note: I edited the password out of the above result.

Perhaps mythweb requires more than just the USAGE permission to run correctly?

I access my mythbackend from remote frontends so I also have the backend configured as a non "localhost" ip address.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by bill6502 »

I've never seen GRANT USAGE. The MythTV recommendation is here:
https://code.mythtv.org/cgit/mythtv/tre ... ase/mc.sql

And if you look at the mysql site (search for: no privileges):
https://dev.mysql.com/doc/refman/5.7/en/grant.html
Linuxgrrl
Junior
Posts: 67
Joined: Mon Oct 26, 2020 12:46 am
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by Linuxgrrl »

Thank you. I did

Code: Select all

mysql> GRANT ALL ON *.* TO mythtv@localhost;
Query OK, 0 rows affected (0.07 sec)
and I got a bit of weird output:

Code: Select all

mysql> SHOW GRANTS FOR 'mythtv'@'localhost';
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for mythtv@localhost                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `mythtv`@`localhost`                                                                                                                                                                                                                    |
| GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `mythtv`@`localhost` |
| GRANT ALL PRIVILEGES ON `mythconverg`.* TO `mythtv`@`localhost`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.04 sec)
And mythweb is still not working, even from localhost. What should I do?
yawlhoo
Senior
Posts: 120
Joined: Wed Apr 15, 2015 4:18 pm
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by yawlhoo »

FWIW, I have:
----
mysql> SHOW GRANTS FOR 'mythtv'@'localhost';
+-----------------------------------------------------------------+
| Grants for mythtv@localhost |
+-----------------------------------------------------------------+
| GRANT USAGE ON *.* TO `mythtv`@`localhost` |
| GRANT ALL PRIVILEGES ON `mythconverg`.* TO `mythtv`@`localhost` |
+-----------------------------------------------------------------+
2 rows in set (0.00 sec)
----
and my mythweb is working fine.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by bill6502 »

@ Linuxgrrl, do this from the command line on the host that the
backend is running on:

Code: Select all

mysql --user=mythtv --password=<yours from config.xml in use> --host=localhost mythconverg
Take MythTV out of the picture. If the above doesn't work, then
MythTV/mythweb won't. If you're connecting to mythweb from a remote host, then
just allowing localhost isn't going to work. But that's true for remote frontends too.

In the initial post, "/.mythtv/config/config.xml" is mentioned. That's not wrong, but
it's odd. Typically, the backend is started by root, but runs as user mythtv.

Be sure to to menion the version of mysql in play as v8 changes some things.
I cited a v5.7 page above.
Linuxgrrl
Junior
Posts: 67
Joined: Mon Oct 26, 2020 12:46 am
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by Linuxgrrl »

Sure enough, when I try to log onto mysql using mythtv's normal password:

Code: Select all

mary@mythbox:~$ mysql --user=mythtv --password
Enter password: [edited out]
ERROR 1045 (28000): Access denied for user 'mythtv'@'localhost' (using password: YES)
Yet mythtv is running fine. I've been deleting, scheduling, watching recordings with no problem - that shouldn't be possible, should it? Mythbackend is running as user mythtv.
Anyhow, I have mysql version 8. I am a complete novice at myql, but when I look at the results of the "SHOW GRANTS" command above, it looks like user mythtv has "ALL PRIVILEGES" on mythconverg, so I'm curious as to what additional privileges I need to provide.
Re the location of the password, thank you for pointing that out. It was a typo on my part. My config.xml is in /home/mythtv/.mythtv/ and has a password that was created by mythtv when I first installed it. That is the password that I'm using when I try to log into mysql as above. Remote frontends have picked up that password automatically and they are working fine for playback.

Should I try to re-set the mythtv mysql password? Bearing in mind that I'm a bit nervous, as mythtv is running very nicely atm and I don't want to break anything :)
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by bill6502 »

If the backend works, then it appears that you're using the wrong password. I'll guess that Mint
uses systemd. This will help you find the config.xml file in use: systemctl cat mythtv-backend
(Mint may use another service name though. I don't know.)

Look for the User= line. It's probably mythtv. Also look for a line similar to this: Environment="MYTHCONFDIR=/var/lib/mythtv/confdir"
and, if set, MYTHCONFDIR overrides the User= line. Check/Recheck the directory/config.xml
for the proper password.

You already mentioned checking the apache2 setup. Be sure it looks similar
to this:

Code: Select all

    setenv db_server        "localhost"
    setenv db_name          "mythconverg"
    setenv db_login         "mythtv"
    setenv db_password      "your pw..."
    
Restart apache2 if changes are made.

mysql v8 changed the syntax of some commands and the site above isn't right.
Linuxgrrl
Junior
Posts: 67
Joined: Mon Oct 26, 2020 12:46 am
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by Linuxgrrl »

Curiouser and curiouser.
my systemd doesn't appear (to me) to point directly to a config.xml:

Code: Select all

mary@mythbox:~$ sudo systemctl cat mythtv-backend
[sudo] password for mary:       
# /lib/systemd/system/mythtv-backend.service
[Unit]
Description=MythTV Backend
Documentation=https://www.mythtv.org/wiki/Mythbackend
After=mysql.service network.target
 
[Service]
User=mythtv
EnvironmentFile=-/etc/mythtv/additional.args
ExecStart=/usr/bin/mythbackend --quiet --syslog local7 $ADDITIONAL_ARGS
StartLimitBurst=10
StartLimitInterval=10m
Restart=on-failure
RestartSec=1
 
[Install]
WantedBy=multi-user.target
The environment file that it points to, "/etc/mythtv/additional.args,' doesn't actually exist:

Code: Select all

root@mythbox:/etc/mythtv# ls
config.xml  session-settings
It seems clear that mythtv-backend is running as mythtv:

Code: Select all

mary@mythbox:~$ ps aux | grep mythb
avahi        724  0.0  0.0   9032  3872 ?        Ss   Feb02   1:08 avahi-daemon: running [mythbox.local]
mythtv     32274  7.1  3.0 4311936 250808 ?      Ssl  Feb03 111:00 /usr/bin/mythbackend --quiet --syslog local7
I got hopeful in looking at /etc/mythtv/config.xml to see if it had a different password, but it contains the same username ("mythtv")/password combo that /home/mythtv/.mythtv/config.xml has (and that works fine for the remote frontends). When I am trying and failing to log into mysql, I am sitting at localhost.

I rechecked /etc/apache2/sites-enabled/mythweb.conf and it looks the same as what you wrote. There is another file in that directory called "000-default-mythbuntu.conf" and I'm not sure if that's a problem -- it looks totally different from the other file and has no username/password in it.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by bill6502 »

mythtv-backend.service doesn't need to point to config.xml. Either the User= $HOME is used (your case)
or MYTHCONFDIR can override it (yours doesn't).

EnvironmentFile can contain values for $ADDITIONAL_ARGS for the ExecStart line and isn't in play here.

Clearly, the backend will look at ~mythtv/.mythtv/config.xml. That is typically a symbolic link to /etc/mythtv/config.xml
as is ~/.mythtv/config.xml. Links have known to get broken and files replace the links. The reason for looking at these
is to verify the password - that works for the backend. The links are a *buntu thing and aren't mandatory.

This is a way to see the backend's connection data without looking in files. You likely need to install libxml2-utils first.
The trailing dash below is required. The Pin is the one you set or it may be 0000 if not set.

Code: Select all

curl --data Pin=xxxx localhost:6544/Myth/GetConnectionInfo | xmllint --format -
Linuxgrrl
Junior
Posts: 67
Joined: Mon Oct 26, 2020 12:46 am
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by Linuxgrrl »

Here are the results. I edited out the password, but it's the same one I've been trying to use when attempting to log in manually to mysql. "<LocalEnabled.false<" seems like maybe a bad thing, but if that's the problem, I'm not sure how to fix?

Code: Select all

mary@mythbox:~$ curl --data Pin=0000 localhost:6544/Myth/GetConnectionInfo | xmllint --format -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   731  100   723  100     8  21264    235 --:--:-- --:--:-- --:--:-- 21500
<?xml version="1.0" encoding="UTF-8"?>
<ConnectionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" serializerVersion="1.1">
  <Version>
    <Version>v31.0+fixes.202102011634.1aff6fd2db~ubuntu20.04.1</Version>
    <Branch>fixes/31</Branch>
    <Protocol>91</Protocol>
    <Binary>31.20200101-1</Binary>
    <Schema>1361</Schema>
  </Version>
  <Database>
    <Host>192.168.1.253</Host>
    <Ping>true</Ping>
    <Port>3306</Port>
    <UserName>mythtv</UserName>
    <Password>MYPASSWORD</Password>
    <Name>mythconverg</Name>
    <Type>QMYSQL</Type>
    <LocalEnabled>false</LocalEnabled>
    <LocalHostName/>
  </Database>
  <WOL>
    <Enabled>false</Enabled>
    <Reconnect>0</Reconnect>
    <Retry>5</Retry>
    <Command>echo 'WOLsqlServerCommand not set'</Command>
  </WOL>
</ConnectionInfo>
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by bill6502 »

You don't have a LocalHostName, so LocalEnabled false is OK (and common).

Bad news is that this is pretty simple, if the mysql command works, then mythweb will.
Or, at least fail for some other reason.

Note the DB host is a Private Network address. If the DB is on the same host as the backend,
then the Host should be localhost (which uses a socket rather than a TCP connection.) That
means that the backend isn't logging into the DB with the same credentials as you're testing
with.


I wouldn't change to HOST localhost right now, as you know from the command line
mysql tests that it will fail.

Replace localhost with 192.168.1.253 in the mysql command and see if it works.

Something like: SHOW GRANTS FOR 'mythtv'@'192.168.1.%'; may be what was added
especially if you have remote frontends.
Linuxgrrl
Junior
Posts: 67
Joined: Mon Oct 26, 2020 12:46 am
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by Linuxgrrl »

Well! It does work. This command:

Code: Select all

mary@mythbox:~$ mysql --user=mythtv --password --host=192.168.1.253 mythconverg
logs me on to the database when I enter the password.
How do I fix it so "localhost" works, along with me connecting to mythweb from my phone?

Here is the output of another mysql query -- it looks like mythtv should be able to log on from anywhere, but cannot:

Code: Select all

mysql> SELECT User,Host FROM mysql.user;
+------------------+-----------+
| User             | Host      |
+------------------+-----------+
| mythtv           | %         |
| debian-sys-maint | localhost |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| mythtv           | localhost |
| phpmyadmin       | localhost |
| root             | localhost |
+------------------+-----------+
8 rows in set (0.00 sec)
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by bill6502 »

See if Mint has an entry in /etc/hosts for localhost. Or, anywhere your backend uses to do hostname resolution.

I recall that localhost must have an entry in the user table as well as the above '%' entry if other hosts are allowed to
access the DB. My user table looks similar to yours for those columns. '%' is a bit too open for me, some folks
don't even like ones like '192.168.1.%'. That's up to you.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: mythweb Access denied for user 'mythtv'@'localhost'

Post by bill6502 »

Left out the simple solution, change setenv db_server "localhost" to use the IP and restart apache2.
Post Reply