[mythtv-users] Upgraded the Ubuntu 11.10 and not Myth can't connect to MySQL

Robert Longbottom rongblor at googlemail.com
Sat Nov 5 13:09:43 UTC 2011

On 05/11/2011 11:45, Damian wrote:
> :-) Thanks Geoff, Bill and John for helping out.

I'll start by saying I've not been following this, but here goes with a 
few suggestions...

> Here's the latest. I've done a lot, and think I've got enough to clarify
> the problem a bit to 'those of you who know', but I'm at the edge of my
> understanding again. Here's where it's at ....
> Both mysql.txt and config.xml contain '' rather than
> 'MythBox', but I think I need to fix my bigger problems with mysql
> before I start messing with the MythTV setup. I can't currently log into
> mysql as root, so trying to fix anything further down the line seems futile.
> I did run:
> /var/run$ chown -R mysql:mysql mysql
> but this just responded:
> chown: cannot access `mysql': No such file or directory
> Should one of those 'mysql's have been 'mysqld'? I assume so, but I
> don't know which one.

Yes, that last one should be mysqld - thats the directory name and the 
command is changing the ownership of that directory to the mysql user 
and group.  Check it's worked with 'ls -la /var/run/mysqld' - you should 
see all file (except the ".." owned by mysql)

> I've just had a look at the /var/run/mysqld folder, and it looks
> completely empty. That doesn't seem like a good thing!???

Thats fine.  It should be empty when mysql isn't running (which it looks 
like it isn't from some of the output you've posted below.

> Have I not even got mysql installed properly anymore?? This is just
> weird. How can an 'upgrade' break things so badly??
> Found this thread:
> http://ubuntuforums.org/showthread.php?t=1601420
> $ sudo chown -R mysql:mysql /var/lib/mysql
> Then rebooted
> $ sudo service mysql status
> mysql respawn/post-start, (post-start) process 3234
> $ mysql -u mythtv -pmythtv mythconverg
> ERROR 2002 (HY000): Can't connect to local MySQL server through socket
> '/var/run/mysqld/mysqld.sock' (2)
> $ ps -A | grep mysql
> Returns nothing

^-- looks like the mysql service is failing to start correctly.

> Tried running mysqld out of bin:
> /usr/bin$ mysqld
> 111105 11:19:20 [Warning] option 'net_buffer_length': unsigned value
> 8388608 adjusted to 1048576
> 111105 11:19:20 [Warning] Can't create test file
> /var/lib/mysql/MythBox.lower-test
> 111105 11:19:20 [Warning] Can't create test file
> /var/lib/mysql/MythBox.lower-test
> mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
> 111105 11:19:20 [ERROR] Aborting
> 111105 11:19:20 [Note] mysqld: Shutdown complete
> Tried running mysqld_safe out of bin:
> /usr/bin$ mysqld_safe
> 111105 11:21:25 mysqld_safe Logging to syslog.
> 111105 11:21:25 mysqld_safe Starting mysqld daemon with databases from
> /var/lib/mysql
> rm: cannot remove `/var/lib/mysql/MythBox.pid': Permission denied
> 111105 11:21:25 mysqld_safe mysqld from pid file
> /var/lib/mysql/MythBox.pid ended
> Im I getting somewhere here? Maybe the hole problem is just down to
> permissions? Or maybe it's permissions and paswords have been changed?
> One thing at a time. What should the permissions on these folders be and
> how do I change them?

Trying to run mysql under your user account (or root) will cause issues 
with permissions because either you wont have access to the mysql files, 
or if you run it as root, then it will create some files that it then 
wont be able to access when you run it as a service because then it will 
(should) run under the mysql user.

> I'm learning, but not enough :-)
> There's this sequence suggested by the guy on the forum thread from last
> year...
>       purge and reinstall mysql server
>       chgrp -R mysql /var/lib/mysql/
>       Check if mysql can run in savemode: /usr/bin: mysqld_safe
>       Somehow I lost my mysql.conf for upstart. So recreate it and paste
> exec sudo -u mysql /usr/sbin/mysqld #<- important execute as use mysql
> but I don't even understand all of that, let alone have confidence in
> accieving it. Nor do I know if it will kill any database I once had
> (which I'm hoping I can keep if possible, although I am losing hope that
> it even exists any more).
> The last thing I did was follow bills advice and run the 'post-start
> script' from /etc/init/mysql.conf maually on the command line. Here's
> the results:
> $ for i in `seq 1 30` ; do
>   >  /usr/bin/mysqladmin --defaults-file="${HOME}"/debian.cnf ping&&  {
>   >  exec "${HOME}"/debian-start
>   >  # should not reach this line
>   >              exit 2
>   >          }
>   >          sleep 1
>   >      done
> Could not open required defaults file: /home/damian/debian.cnf
> Fatal error in defaults handling. Program aborted
> /usr/bin/mysqladmin: connect to server at 'localhost' failed
> error: 'Can't connect to local MySQL server through socket
> '/var/run/mysqld/mysqld.sock' (2)'
> Check that mysqld is running and that the socket:
> '/var/run/mysqld/mysqld.sock' exists!
> Could not open required defaults file: /home/damian/debian.cnf
> Fatal error in defaults handling. Program aborted
> /usr/bin/mysqladmin: connect to server at 'localhost' failed
> error: 'Can't connect to local MySQL server through socket
> '/var/run/mysqld/mysqld.sock' (2)'
> Check that mysqld is running and that the socket:
> '/var/run/mysqld/mysqld.sock' exists!
> etc etc repeat to infinity
> I then tried Bill's test to see if my mythconverg database was still
> there .. and I think it is! :-) Here's the results:
> $ sudo -i
> root at MythBox:~#    cd /var/lib/mysql/mythconverg
> root at MythBox:/var/lib/mysql/mythconverg#    ls -l
> total 19748
> -rw-rw---- 1 mysql mysql    9255 2011-05-09 07:53 archiveitems.frm
> -rw-rw---- 1 mysql mysql       0 2011-10-27 08:11 archiveitems.MYD
> -rw-rw---- 1 mysql mysql    2048 2011-10-27 08:11 archiveitems.MYI
> -rw-rw---- 1 mysql mysql    8630 2011-05-09 07:53 callsignnetworkmap.frm
> -rw-rw---- 1 mysql mysql       0 2011-10-27 08:11 callsignnetworkmap.MYD
> -rw-rw---- 1 mysql mysql    1024 2011-10-27 08:11 callsignnetworkmap.MYI
> -rw-rw---- 1 mysql mysql    9752 2011-05-09 07:53 capturecard.frm
> -rw-rw---- 1 mysql mysql     328 2011-10-27 08:11 capturecard.MYD
> and lots more of this .. as expected.

Looks like your db is there, which is a good start.  I'd say that 
following the complete remove and reinstall risks loosing that.

> Ok, my head hurts now. Where next?

Have you checked the mysql log files in /var/log/mysql?  I'd suggest you 
go into /var/log/mysql, delete any existing log files (maybe take a copy 
elsewhere just in case).  Check that the /var/log/mysql directory is 
owned and writable by the mysql user.  Then try and start the mysql 
service.  Check to see if the process is running and then check the log 
files to see what they say.  So, commands something like this:

# cd /var/log/mysql

# sudo rm *.err *.log

# ls -la /var/log/mysql
Check that the . directory is owned by mysql and is writeable eg:
robert at quad ~ $ ls -la /var/log/mysql/
total 4872
drwxr-xr-x  2 mysql mysql    4096 May 13 14:40 .
drwxr-xr-x 19 root  root     4096 Nov  2 03:15 ..

# sudo service mysql start (?? I assume this is how you start service on 
Ubuntu based on your postings above - I'm not a Ubuntu user, so I'm not 

Wait a few seconds

# ps ax |grep -i mysql

Based on your output above, I'd expect this to report that it isn't running.

# cat /var/log/mysql/*.err /var/log/mysql/*.log

And see what falls out.

If it looks like permissions, post and much 'ls -la' output as you can 
from the various mysql directories including

Hoepfully someone will be able to spot the problem

Good luck!

More information about the mythtv-users mailing list