[mythtv-users] How to repair mysql?

UB40D ub40dd at googlemail.com
Sun Mar 10 21:15:10 UTC 2013


Thanks a lot for this, Mike, this sounded like a useful thing to try at
this stage.


On Sun, Mar 10, 2013 at 8:27 PM, Mike Perkins
<mikep at randomtraveller.org.uk>wrote:

> Since you have gone over this several times with more or less the same
> results I'm beginning to wonder if you have a file, files or directory
> which the installation process needs to write to but can't.
>
...

>
> First of all, attempt to uninstall everything so that in theory you have a
> fresh system to start from. Then, look around your file system for
> remaining files: try /var/lib/mysql, /var/run/mysql, /var/log/mysql and
> /etc/mysql but there may be other locations. If you find any files in these
> directories it is possible that they may have the wrong permissions and are
> blocking the installation.
>

I could see the permissions of those files but could not tell by whom they
had to be readable or writable in a working setup.

So I thought: let me try on another computer. It didn't have mysql-server
installed. I did sudo apt-get install mysql-server and got no errors, and
typing mysql gave me a prompt. So at least I'd have a kind of reference
installation I could compare the "right" permissions against.

Anyway, having done that I thought: how about moving all those directories
you mentioned out of the way, and attempting a reinstall? Shouldn't that
(hopefully) work as on the other computer? Of course the mysql would no
longer have myth in there, but I figured I could copy it back in later,
with appropriate permissions, if everything worked. But it seems not to
have worked: it gave similar errors to before. I can't figure it out. I
have listed all the permissions of the directories so you can tell me if
you spot anything obviously wrong.



> (Of course, if you had a previous mythtv database, I'm assuming you have a
> suitable backup already?)
>

Well, I did take a copy of /var on another physical drive when I started
those rescue operations. Still, I only moved those directories to .bak
rather than deleting them, as you'll see below.

Also look at /etc/init.d/mysql and see what the "start" option references.
> See if you can determine what it wants to do and why it fails.
>

I had a look but got no enlightenment from it. Maybe you can read more into
it than I did (see end of listing).



# dpkg -P mysql-server-5.5 mysql-server(Reading database ... 322308 files
and directories currently installed.)
Removing mysql-server-5.5 ...
Purging configuration files for mysql-server-5.5 ...
dpkg: warning: while removing mysql-server-5.5, directory
'/usr/share/doc/mysql-server-5.5' not empty so not removed
Removing mysql-server ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...

# dpkg -l mysql-server mysql-server-5.5
Desired=Unknown/Install/Remove/Purge/Hold
|
Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
un  mysql-server   <none>                    (no description available)
dpkg-query: no packages found matching mysql-server-5.5


-------------------------
OK, removed as far as we can tell.

Now for each of the dirs you mentioned I list the current permissions and
then I move it out of the way.
-------------------------


# ls -ld /var/lib/mysql/
drwx------ 6 mysql mysql 4096 Mar 10 17:33 /var/lib/mysql/

# ls -l /var/lib/mysql/
total 32
-rwxr-xr-x 1 mysql mysql     0 Mar 10 17:32 debian-5.5.flag
-rw-rw---- 1 mysql mysql     0 Mar  3 13:26 ibdata1
drwx------ 2 mysql mysql  4096 Mar  3 13:23 mysql
-rwxr-xr-x 1 mysql mysql     6 Jan 23 23:06 mysql_upgrade_info
drwxr-xr-x 2 mysql mysql 16384 Dec 16 23:06 mythconverg
drwx------ 2 mysql mysql  4096 Mar 10 17:32 performance_schema
drwxr-xr-x 2 mysql mysql  4096 Aug 18  2012 test

# mv /var/lib/mysql /var/lib/mysql.bak



# ls -ld /var/run/mysqld/
drwxr-xr-x 2 mysql root 40 Mar  8 20:16 /var/run/mysqld/

# ls -l /var/run/mysqld/
total 0

# mv /var/run/mysqld /var/run/mysqld.bak



# ls -ld /etc/mysql/
drwxr-xr-x 3 root root 4096 Mar 10 20:45 /etc/mysql/

# ls -l /etc/mysql/
total 12
drwxr-xr-x 2 root root 4096 Mar 10 20:45 conf.d
-rw------- 1 root root  333 Aug 18  2012 debian.cnf
-rw-r--r-- 1 root root 3505 Jan 16 20:47 my.cnf

# mv /etc/mysql /etc/mysql.bak



# ls -ld /var/log/mysql
drwxr-s--- 2 mysql adm 4096 Mar 10 07:55 /var/log/mysql

# ls -l /var/log/mysql
total 92
-rw-r----- 1 mysql adm 55463 Mar 10 17:33 error.log
-rw-r----- 1 mysql adm  1475 Mar  9 18:45 error.log.1.gz
-rw-r----- 1 mysql adm  4066 Mar  8 22:34 error.log.2.gz
-rw-r----- 1 mysql adm    20 Mar  7 07:49 error.log.3.gz
-rw-r----- 1 mysql adm    20 Mar  6 07:37 error.log.4.gz
-rw-r----- 1 mysql adm    20 Mar  5 07:56 error.log.5.gz
-rw-r----- 1 mysql adm    20 Mar  4 07:43 error.log.6.gz
-rw-r----- 1 mysql adm  6314 Mar  3 14:55 error.log.7.gz

# mv /var/log/mysql /var/log/mysql.bak


------------------------
...and I double-check that I moved ALL of them out of the way.
-----------------------

# ls -ld /var/lib/mysql /var/run/mysql /var/log/mysql /etc/mysql
ls: cannot access /var/lib/mysql: No such file or directory
ls: cannot access /var/run/mysql: No such file or directory
ls: cannot access /var/log/mysql: No such file or directory
ls: cannot access /etc/mysql: No such file or directory


------------------------
OK. So now I hope this is going to be a clean install at last
------------------------


# apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  mysql-server-5.5
Suggested packages:
  tinyca mailx
The following NEW packages will be installed:
  mysql-server mysql-server-5.5
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/8,851 kB of archives.
After this operation, 32.8 MB of additional disk space will be used.
Do you want to continue [Y/n]?
Preconfiguring packages ...
Selecting previously unselected package mysql-server-5.5.
(Reading database ... 322221 files and directories currently installed.)
Unpacking mysql-server-5.5 (from
.../mysql-server-5.5_5.5.29-0ubuntu0.12.10.1_amd64.deb) ...
egrep: /etc/mysql/: No such file or directory
Selecting previously unselected package mysql-server.
Unpacking mysql-server (from
.../mysql-server_5.5.29-0ubuntu0.12.10.1_all.deb) ...
Processing triggers for ureadahead ...
Processing triggers for man-db ...
Setting up mysql-server-5.5 (5.5.29-0ubuntu0.12.10.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for ureadahead ...
No apport report written because the error message indicates its a followup
error from a previous failure.
                          Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)


----------------------------------
Damn.

And here's the other file you suggested I look at
-----------------------------------


# cat /etc/init.d/mysql
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.

set -e

INITSCRIPT="$(basename "$0")"
JOB="${INITSCRIPT%.sh}"

if [ "$JOB" = "upstart-job" ]; then
    if [ -z "$1" ]; then
        echo "Usage: upstart-job JOB COMMAND" 1>&2
exit 1
    fi

    JOB="$1"
    INITSCRIPT="$1"
    shift
else
    if [ -z "$1" ]; then
        echo "Usage: $0 COMMAND" 1>&2
exit 1
    fi
fi

COMMAND="$1"
shift


if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
ECHO=echo
else
ECHO=:
fi

$ECHO "Rather than invoking init scripts through /etc/init.d, use the
service(8)"
$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"

# Only check if jobs are disabled if the currently _running_ version of
# Upstart (which may be older than the latest _installed_ version)
# supports such a query.
#
# This check is necessary to handle the scenario when upgrading from a
# release without the 'show-config' command (introduced in
# Upstart for Ubuntu version 0.9.7) since without this check, all
# installed packages with associated Upstart jobs would be considered
# disabled.
#
# Once Upstart can maintain state on re-exec, this change can be
# dropped (since the currently running version of Upstart will always
# match the latest installed version).

UPSTART_VERSION_RUNNING=$(initctl version|awk '{print $3}'|tr -d ')')

if dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 0.9.7
then
    initctl show-config -e "$JOB"|grep -q '^  start on' || DISABLED=1
fi

case $COMMAND in
status)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted
to an"
    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g.
$COMMAND $JOB"
    $COMMAND "$JOB"
    ;;
start|stop)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted
to an"
    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g.
$COMMAND $JOB"
    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
        RUNNING=1
    fi
    if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
        exit 0
    elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
        exit 0
    elif [ -n "$DISABLED" ] && [ "$COMMAND" = "start" ]; then
        exit 0
    fi
    $COMMAND "$JOB"
    ;;
restart)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted
to an"
    $ECHO "Upstart job, you may also use the stop(8) and then start(8)
utilities,"
    $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also
available."
    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
        RUNNING=1
    fi
    if [ -n "$RUNNING" ] ; then
        stop "$JOB"
    fi
    # If the job is disabled and is not currently running, the job is
    # not restarted. However, if the job is disabled but has been forced
into the
    # running state, we *do* stop and restart it since this is expected
behaviour
    # for the admin who forced the start.
    if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
        exit 0
    fi
    start "$JOB"
    ;;
reload|force-reload)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted
to an"
    $ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload
$JOB"
    reload "$JOB"
    ;;
*)
    $ECHO
    $ECHO "The script you are attempting to invoke has been converted to an
Upstart" 1>&2
    $ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
    exit 1
esac
#


-------------------------------
I can't figure out why the install gave an error if I had seemingly moved
out of the way all remaining traces of mysql. Can you?
-------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20130310/e0f66138/attachment.html>


More information about the mythtv-users mailing list