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

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

Moderator: Forum Moderators

piper
Newcomer
Posts: 2
Joined: Sat Feb 15, 2014 1:26 pm
United States of America

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by piper »

curracruisers wrote:I have not bothered to check this post for a while. But I have just done another clean install using LM17.1, Mythtv 0.27. and guess what? It's still there!!! I don't expect a solution because the developers don't believe this to be a Mythtv/mysql issue. rwagner's last post says it is a mythbuntu issue, ignoring the fact that the issue is there in Fedora and Suse both of which do not use mythbuntu repos.
I still reckon even rwagner can't do a clean install, OS and mythtv and have it work out of the box (NO FIDDLING).
If he can, he should let us know how to do it.

I use debian sid (siduction) and no, it don't "work out of the box", but 5 minutes later I have a working system.

Code: Select all

apt-get update && apt-get install mysql-server-5.5 mysql-workbench mysql-utilities mythtv mythweather  mythtv-status libyaml-shell-perl libyaml-libyaml-perl libyaml-syck-perl libmythtv-perl libnet-upnp-perl

Code: Select all

grant all privileges on mythconverg.* to mythtv@"whatever ip you use" identified by "mythtv"; flush privileges;

Code: Select all

passwd mythtv

Code: Select all

usermod -a -G mythtv piper

Code: Select all

mythtv-setup
That takes roughly a minute if that, the other 4 minutes is in settings, setting up tuners, etc.

When done do

Code: Select all

mythfilldatabase --dd-grab-all
It works and works well :)
apt-get into it | debian sid/siduction
gregb49
Newcomer
Posts: 13
Joined: Tue Mar 17, 2015 4:40 pm
Great Britain

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by gregb49 »

piper wrote:
curracruisers wrote:...I still reckon even rwagner can't do a clean install, OS and mythtv and have it work out of the box (NO FIDDLING).
If he can, he should let us know how to do it.
I use debian sid (siduction) and no, it don't "work out of the box", but 5 minutes later I have a working system.

Code: Select all

apt-get update && apt-get install mysql-server-5.5 mysql-workbench mysql-utilities mythtv mythweather  mythtv-status libyaml-shell-perl libyaml-libyaml-perl libyaml-syck-perl libmythtv-perl libnet-upnp-perl
Tried all that but couldn't get beyond

Code: Select all

Could not open lock file /var/lib/dpkg/lock
I tried restarting the computer, but to no avail. Like "curracruisers" I am trying on a clean Ubuntu Mate 14:04 install. I have tried mythtv through synaptic, tried a total remove on Mythtv then an install of Mythbuntu but to no avail. A clean install of mythbuntu on its own, as a separate OS. It works out of the box, but using Mate, I just cannot seem to get past the
Myth TV could not connect to the database
error code. I looked at ~mythtv/.mythtv/config.xml and the user name and password are correct. Where to now?
gregb49
Newcomer
Posts: 13
Joined: Tue Mar 17, 2015 4:40 pm
Great Britain

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by gregb49 »

Just tried a clean install of Linux Mint LMDE, that is Mint based only on Debian, hoping that that might be simpler. The only extra that I have installed is MythTV, on top of this totally clean install.
Low and behold, I get the dreaded
Myth TV could not connect to the database
result. Is there anyone out there who can help this non-MqSQL expert out of this fix? Why is this all so difficult? curracruisers has a very good point.
gregb49
Newcomer
Posts: 13
Joined: Tue Mar 17, 2015 4:40 pm
Great Britain

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by gregb49 »

LowellStewart wrote:.. I did not know where the real password was. It turns out it is in ~mythtv/.mythtv/config.xml.
Unfortunately, ~mythtv/.mythtv/config.xml just shows the password to be mythtv, or at least that was the case in my set up, before I managed to get the backend setup out of its country selection infinite loop.

As usual, the answer proved to be simple, but has taken me 3 days to find it. Surely setting up mythtv on debian or ubuntu should not be that difficult. I've written the following in the simple terms that even I can understand, so that it might help someone else and prevent them from reading through countless MySQL instructions, which, in the end, took me no further forward.

My synaptic installation of Mythtv had set the database password up as mythtv but this was incorrect. I found the correct password in
/etc/mythtv/config.xml
but that cannot be read by your text editor unless you open it as a superuser. So, open a terminal, and start up your text editor using sudo gedit (or whatever your text editor is). You will see something like

<Host>localhost</Host>
<UserName>mythtv</UserName>
<Password>J7fTG8hVF5kGcDkL</Password> (I've changed this from my actual password)
<DatabaseName>mythconverg</DatabaseName>

Then start up your mythtv backend and put in the new password - voilà. As curracruisers says:
curracruisers wrote:Why? Why? Why? after all these years does a simple stand alone single system Ubuntu/Linuxmint not install correctly?
User avatar
dizygotheca
Developer
Posts: 267
Joined: Wed Sep 03, 2014 9:02 am
Great Britain

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by dizygotheca »

A belated response. However an explanation is often useful...

For *buntu, this is caused by the packaging error documented by https://bugs.launchpad.net/mythbuntu/+bug/1389741 and its (rather ancient) duplicate.

The packages attempt to configure a password before pwgen is installed, which results in different passwords being set in MySql. Unfortunately reconfiguring or purging/reinstalling Mythtv or MySql doesn't clear the corrupted passwords.

Myth requires the password to be set in 4 places;
  1. /etc/mythtv/config.xml for the backend
  2. /home/<user>/.mythtv/config.xml for the frontend
  3. MySql access
  4. MySql permissions
To examine the (encrypted) MySql passwords:

Code: Select all

$ mysql -p -u root mythconverg
Enter password: Use the admin password you set when MySql was installed
mysql> select user,host,password from mysql.user where user = 'mythtv';
mysql> show grants for mythtv;
mysql> exit
You can guess the Db password encryption (it's probably defaulted to 'mythtv'):

Code: Select all

mysql> select password('mythtv');
A fix was released in Jan 2015 but, until verified (or as a safeguard), you can avoid the problem by ensuring pwgen is installed before mythtv

Code: Select all

$ sudo apt-get install pwgen
Then Myth will work 'out-of-the-box'.

Note. MythTV maintain the code (in github) only. Repository packages are provided by the Mythbuntu team who also provide the Mythbuntu distro separately.
The main Ubuntu repositories always contain old releases (currently 1 year out-of-date) so you should always install from the up-to-date Mythbuntu repository.
Apart from getting the current Mythtv version, you will also avoid old packaging bugs, such as this.

Code: Select all

$ sudo apt-add-repository ppa:mythbuntu/0.27
$ sudo apt-get update
To fix a broken installation (combined BE/FE);
  1. Remove configuration files

    Code: Select all

    $ sudo rm /etc/mythtv/config.xml /home/<user>/.mythtv/config.xml  
    
  2. Clear database configuration

    Code: Select all

    $ mysql -p -u root mythconverg
    Enter password: Use the admin password you set when MySql was installed
    mysql> drop user 'mythtv'@'%';
    mysql> drop user 'mythtv'@'localhost';
    mysql> flush privileges;
    mysql> exit
    
  3. Reconfigure myth. If you don't specify a password, a 28-char random one will be generated.

    Code: Select all

    $ sudo dpkg-reconfigure mythtv-common
    $ sudo dpkg-reconfigure mythtv-database
    $ ln -s /etc/mythtv/config.xml /home/<user>/.mythtv/
    
  4. When testing, remember to run the backend as the mythtv user to ensure the correct configuration file is used.

    Code: Select all

    $ sudo -H -u mythtv mythbackend
    
Last edited by dizygotheca on Mon May 11, 2015 8:49 am, edited 2 times in total.
gregb49
Newcomer
Posts: 13
Joined: Tue Mar 17, 2015 4:40 pm
Great Britain

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by gregb49 »

dizygotheca wrote:A belated response. However an explanation is often useful...
Yes, very useful thanks and gives me confidence to try a fresh install as my current Xubuntu 14.04 works with MythTV, but crashes every few days for some unknown reason.
gregb49
Newcomer
Posts: 13
Joined: Tue Mar 17, 2015 4:40 pm
Great Britain

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by gregb49 »

Ah, mine crashes every few days as well, in fact, getting closer to every day now, and I don't know why. I've tried a few re-installs with different distros to no avail. I hate to admit it but win8 is rock steady, so I don't think this is a hardware problem, probably more to do with my VIA graphics chip. However, mythtv works on another computer, so I've now given up on the crashing one.
horvath62
Newcomer
Posts: 3
Joined: Thu Oct 08, 2015 2:59 pm
United States of America

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by horvath62 »

I feel your pain curracruiser. I too have been beating my head against the wall for almost week trying to install mythtv.

And I agree it should just work out of the box, without ever opening a console. Mythtv is not quite there yet, but its lightyears ahead of where it was a decade ago, where it took me months to getting working right. This time around it took a few days. If I had the time I would re-image my drive and start over and take close notes...maybe another day.

THIS IS NOT A COMPLETE INSTALLATION GUIDE, BUT THE BASIC FLOW WITH WHERE I THINK A LOT PEOPLE HITS SNAGS (maybe this works for you):
* First install Ubuntu 14.04LTS (updated with 16.04.1) with your favorite user name and password. The user doesn't have to be "mythtv", though some people swear its necessary...
* Force a static IP (this is a critical step for any real server, lots of good info online to do this. Make sure your router is configured correctly)
* Install synaptic - yes through a terminal window using apt-get command (its a GUI frontend to the installer, this is great and recommended Ubuntu tool to make all your dependencies get installed so you should never have to use a terminal to "fiddle" during installs again, in theory)
* Installed mythtv from synaptic ( make sure the myth-common, mythbackend, mythfrontend and mythweb are checked for install. They should be checked automatically if you check the myth-core box)
* When the install is done it will start asking a bunch of questions, and this is the critical part. If you mess up then it might not work as planned. The good news is that you can re-run the GUI wizards ( yes launched from a console) with:
sudo dpkg-reconfigure mythtv-database
sudo dpkg-reconfigure mythtv-common

* The user you setup on Ubuntu needs to be added to the mythtv group,
substitute your user name for <userid>. From console:
sudo usermod -a -G mythtv <userid>

* Run mythtv-setup (from console) and make sure to change the master IP and backend IP to the static IP address you initially setup.
There's a whole bunch of stuff you can adjust in mythtv-setup. 99% of it is unnecessary for the initial instal. You can go back later and play with it after you get it working correctly.
* In mythtv-setup, you will need to setup your specific tv tuner card, you might need to do specific driver configurations depending on your tuner card.
* I recommend setting up an account at schedulesdirect.org for tv listing service. It only $25 a year at the time of this writing, it was originally created specially for mythtv user long ago under a special contractual agreement with Tribune, the mothership of tv listings.
* Also in mythtv setup you will need to point to a directory that holds the recordings. Create the directory on storage device (HDD). I set the permissions wide open with:
sudo chmod 777 <mystoragedirectory>
Though you might find more restrictive access that still works...
* Also make sure the user for the database in mythtv-setup is "mythtv", the password is "mythtv" and the database is "mythconverg" (which should be the defaults)
* Open a browser from your server or any PC/laptop on your network and type in the static IP you setup.
And guess what, you get: Access denied for user 'mythtv'@'localhost'
It would be nice if the mythtv install fixed this, but for now you will have to configure the web server manually for getting the permission to work:
Edit this file: /etc/apache2/sites-available/mythweb.conf
The password is buried in this file. It gets hashed to some odd string. db_passwd needs to be change to "mythtv". I have the password in plain English, though there is a way to scramble the password. You'll need to dig in a little to figure that out.
Apparently, SQL version incompatibility may require this addition to the /etc/mysql/conf.d/mythtv.cnf file: sql_mode=NO_ENGINE_SUBSTITUTION

restart the web server or better yet just reboot the server.

Now go back to your browser and hopefully you will see mythweb in all its glory!

Hopefully that will help you and others....
Last edited by horvath62 on Mon Aug 08, 2016 3:43 am, edited 6 times in total.
gregb49
Newcomer
Posts: 13
Joined: Tue Mar 17, 2015 4:40 pm
Great Britain

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by gregb49 »

Thanks. That's a useful guide.
Proton23
Newcomer
Posts: 10
Joined: Fri Apr 22, 2016 10:47 pm
Germany

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by Proton23 »

Hi,

after countless hours of searching I finally found this thread, giving me the solution for my problem.
But my problem was, running mythbackend as proton. Today I found a thread with somebody having the same problem what gave me the hint trying to run mythbackend as user mythtv, getting the error 'Access denied for user 'mythtv'@'localhost' which lead me to this thread and to my long-awaited solution.


I think the password in ~mythtv/.mythtv/config.xml should NOT differ from the one set as default in mythbackend.
But may be I just don't get why this is.
Nevertheless, thanks a lot!

Best regards
Proton
User avatar
bill6502
Developer
Posts: 2325
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by bill6502 »

Proton23 wrote:...
I think the password in ~mythtv/.mythtv/config.xml should NOT differ from the one set as default in mythbackend.
...
Proton
You're correct, for almost all cases, there will be a single password in all config.xml files.
It must match the one stored in the database. There are cases for folks with multiple master
backends (therefore databases) or multiple versions of MythTV etc. where having
different passwords and even different database names is useful. But, again, most
users will have just one MythTV DB password -- everywhere.
Neophraz
Newcomer
Posts: 5
Joined: Tue Jun 14, 2016 10:25 pm
United States of America

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by Neophraz »

I've had the exact same problem for the past few years. I just installed Mythbutu instead. Unfortunately, I'm back here looking for a solution again (which I could never find before) since I've been notified that Mythbuntu is out of support. So, I've installed Ubuntu 16.04.2 LTS 4 times on 2 different machines (including the machine that ran Mythbuntu) with this exact same problem. So far I've got one to work by forcing it to use the root user mysql account as wide open to the world as I could make it. Always takes multiple tries to figure out something that works. I feel sorry for anyone that is new to this. Good luck figuring out how to get it working.
perkins1724
Junior
Posts: 33
Joined: Tue Nov 18, 2014 7:44 am
Australia

Re: Access denied for user 'mythtv'@'localhost' (using passw

Post by perkins1724 »

Hi Neophraz, sorry to hear you are having troubles.

Some of this thread is pretty old so I will ignore the background for now.

Just to double check / confirm:
- Have you already run mythtv-setup? In particular section 1 General, section 2 Capture Card and section 7 Storage Directories?
- Is the backend running. Try this to check:

Code: Select all

systemctl status mythtv-backend.service
If yes to both the above, then add this symlink and try to restart the frontend again (replace user with your desktop user name). If /home/user/.mythtv/config.xml already exists back it up somewhere and then delete it and replace with the symlink.

Code: Select all

ln -s /etc/mythtv/config.xml /home/user/.mythtv/config.xml

I just spun up a Ubuntu 16.04 LTS from scratch. My full steps in a slightly abbreviated writeup as follows. If you still have troubles try stepping through this to see if there are any differences. My steps were (start from pristine clean Ubuntu 16.04):

Code: Select all

sudo apt-get update
sudo apt-get upgrade
lots of waiting to get everything up to date. Then:

Code: Select all

apt-cache policy mythtv
showed 2:0.28.0+fixes.20160413 which is about a year old so then:

Code: Select all

sudo add-apt-repository ppa:mythbuntu/0.28
sudo apt-get update
sudo apt-get upgrade
bit more waiting, then:

Code: Select all

apt-cache policy mythtv
showed 2:0.28+fixes.20170329 which is much better. Install mythtv:

Code: Select all

sudo apt-get install mythtv
Follow the prompts. Then:

Code: Select all

mythtv-setup
Selected country and language. I don't have a capture card I could easily install so skipped capture cards and video sources but completed section 1 General for a local install and section 7 with just a single "default" storage group pointing to /tmp
Exited and followed the prompts to allow the backend to be started. Check that the backend is now running:

Code: Select all

systemctl status mythtv-backend.service
Tried the frontend

Code: Select all

mythfrontend
Failed. couldn't access database and pops into country / language screens. Exited. Tried:

Code: Select all

ln -s /etc/mythtv/config.xml /home/user/.mythtv/config.xml
Try the frontend again:

Code: Select all

mythfrontend
Success. Somewhere in there I had to log out and log in again after my desktop user was added to group mythtv but I forget at exactly which point that happened. I basically just followed the prompts. Hope this helps.

To be honest - (full disclosure I am not a Ubuntu user) but it's not immediately clear to me how it is intended for that initial config file to be found. I wonder whether there is a MYTHCONFDIR environment variable needed or something similar. The issue is probably that they can't default a config file because the same package gets used on a frontend only install and on a frontend only install the config file needs to be sourced from the backend where-ever it is.
cerickson
Newcomer
Posts: 5
Joined: Sun Aug 20, 2017 11:02 pm
United States of America

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

Post by cerickson »

It's six years later and these issues still occur.
Post Reply