LinHES Forums
http://forum.linhes.org/

Power loss, now MYSQL wont start
http://forum.linhes.org/viewtopic.php?f=6&t=19737
Page 1 of 2

Author:  scanman717 [ Thu Mar 26, 2009 7:01 pm ]
Post subject:  Power loss, now MYSQL wont start

knoppmyth r5f27

Had a power outage the other day... Backup battery didn't hold.
:(

This is what I get when I try and start mythbackend from root prompt

2009-03-26 20:01:24.266 Using runtime prefix = /usr
2009-03-26 20:01:24.319 New DB connection, total: 1
2009-03-26 20:01:24.322 Unable to connect to database!
2009-03-26 20:01:24.322 Driver error was [1/2002]:
QMYSQL3: Unable to connect
Database error was:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
2009-03-26 20:01:24.377 DB Error (KickDatabase):
Query was:
SELECT NULL;
No error type from QSqlError? Strange...
2009-03-26 20:01:24.429 Failed to init MythContext, exiting.


I have no clue where to start to figure this one out... Is there a way to re-install mysql and re-use the existing DB's???

Thanks!!

Author:  tjc [ Thu Mar 26, 2009 7:56 pm ]
Post subject: 

http://www.knoppmythwiki.org/index.php?page=DisasterRecovery
Actually this one is probably more useful... http://www.knoppmythwiki.org/index.php?page=RepairingMythConvergDB

Author:  scanman717 [ Thu Mar 26, 2009 8:47 pm ]
Post subject: 

Yeah, Disaster recovery is not really what I am after.. If it gets that far, I will just go with a new hard drive and start over...

Tried the Repair MythConvergDB Wiki article.. No luck.

Still getting the unable to connect message...

When I try and start mysql I get : DBI connect('database=mythconverg:host=mythtv','mythtv',...) failed: Can't connect to MySQL server on 'mythtv'

MySQL is not starting..

Mar 26 21:42:14 mythtv /etc/init.d/mysql[6547]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'$
Mar 26 21:42:14 mythtv /etc/init.d/mysql[6547]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

Author:  tjc [ Fri Mar 27, 2009 10:44 pm ]
Post subject: 

Have you tried starting the mysql server manually and/or checking the log files at /var/log/mysql.log, /var/log/mysql.err or in the /var/log/mysql directory?

Code:
/etc/init.d/mysql stop ; sleep 5 ; /etc/init.d/mysql start

Author:  scanman717 [ Sat Mar 28, 2009 7:32 am ]
Post subject: 

Yep..

Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!

Those logfiles are empty... and in /var/log/mysql there are some files from 2007....

:?

I think I may try an auto update.

Author:  tjc [ Sat Mar 28, 2009 3:38 pm ]
Post subject: 

Have you tried the optimize_db.sh script? It falls back on a slower low level repair method that may work where the faster/simpler one doesn't.

OBTW, you might also want to try repairing the mysql schema since that could also be roached.

Author:  scanman717 [ Sat Mar 28, 2009 8:48 pm ]
Post subject: 

Yep. Ran that script. Also did it by hand....

How do I repair the MySQL Schema??? Not a software guy... Routers and Switches all day long, but not so much on the software. :lol:

BTW, thanks tjc, I really appreciate the assistance.

Author:  tjc [ Sat Mar 28, 2009 9:24 pm ]
Post subject: 

Look at the commands inside the script. Instead of the mythconverg directory you want to go to the mysql directory, then run the myisamchk command (as root of course)...
Code:
cd /var/lib/mysql/mysql
/usr/bin/myisamchk --safe-recover *.MYI

The script tries to do this both intelligently and safely (shutting down servers, trying the fast way first, ...) but it's wired up to only work for the myth DB rather than the mysql master schema.

Author:  scanman717 [ Sat Mar 28, 2009 10:30 pm ]
Post subject: 

Still no go...

Also tried:
Code:
 mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
Enter password:
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect
root@mythtv:/home/mythtv#


Is there a lock file or something that might not have cleared when it lost power??

If all else fails, can I simply re-install the MySQL portion of knoppmyth? Or maybe just the tables?? I mean I don't really care about the data in the DB, I can reset my schedules, and everything I recorded that I wanted to keep is elsewhere. I just have lots of other stuff running on this box that I would not rather go through the hassles of doing a full re-install

Author:  scanman717 [ Sat Mar 28, 2009 10:57 pm ]
Post subject: 

Ok, more info.....

As root I ran:
Code:
 mysqld_safe --skip-grant-tables &


Then in another terminal window, as root I started mythbackend.. It appears to run correctly..

Right now it is running.... But this is not optimal.. So how do I get it back to running the way it should??

Author:  tjc [ Sun Mar 29, 2009 10:20 am ]
Post subject: 

Excellent! That sounds much more hopeful. I was afraid that your mythconverg DB was badly corrupted and a backup/restore would just recreate the same issues. While I should probably know how to re-init the mysql DB manually, it's generally easier to do a backup and "auto-upgrade" to the same version. See the R5.5 hints for some things to do to make sure you capture all your tweaks.

OBTW - If you run into a problem with the backup, stop and holler. It may or may not be something you can ignore but it may not be obvious which.

Author:  pmljr [ Sun Apr 19, 2009 6:55 pm ]
Post subject:  mysql won't start after power loss

I've just suffered the same problem. Lost power and now on boot I get this:
    Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
I have run the repair sequence:
Code:
cd /var/lib/mysql/mythconverg
/etc/init.d/mythtv-backend stop
/etc/init.d/mysql stop
myisamchk -f -r *.MYI
then attempted to restart mysql by:
Code:
/etc/init.d/mysql start
which results in:
    Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
When I try:
Code:
mysqlcheck -c -umythtv -pmythtv mythconverg

I get this message:
    mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mythsqld/mysqld.sock' (2) when trying to connect

So I'm wondering if anyone has recovered from this.
I can reinstall the whole thing, but then what happens next time the power drops out? I'd rather figure out how to fix it.
Perhaps there is some way to fix mysql without doing a full reinstall.
Ideas?

Author:  scanman717 [ Sun Apr 19, 2009 7:55 pm ]
Post subject: 

So far I have done nothing else.. Still running the way I did in the last post and it is running fine... Of course everytime I reboot I have to manually do the commands.... But, I don't have time to re-install right now.

I would love to hear if there is a solution out there?

Author:  tjc [ Mon Apr 20, 2009 9:42 am ]
Post subject: 

What do this show?
Code:
ls -al /var/run/mysqld /var/lib/mysql

You may also want to try to start the DB manually as above and check the mysql.user table. There should be 4 rows, "root", "debian-sys-maint", and two "mythtv" enties (one for local access and the other for remote),

Author:  pmljr [ Mon Apr 20, 2009 6:04 pm ]
Post subject:  Response to tjc

The response to the command:
Code:
ls -al /var/run/mysqld /var/lib/mysql
was
/var/lib/mysql:
total 20552
drwxr-xr-x 5 mysql mysql 4096 Apr 19 21:01 .
drwxr-xr-x 44 root root 4096 Apr 20 2008 ..
-rw-r--r-- 1 mysql mysql 0 Jun 2 2007 debian-5.0.flag
-rw-rw---- 1 mysql mysql 5242880 Apr 19 21:01 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Nov 5 2006 ib_logfile1
-rw-rw---- 1 mysql mysql 10485760 Apr 18 20:44 ibdata1
drwxr-xr-x 2 mysql mysql 4096 Apr 18 22:14 mysql
-rw------- 1 mysql mysql 4 Nov 5 2006 mysql_upgrade.info
-rw------- 1 root root 6 Jun 2 2007 mysql_upgrade_info
drwx------ 2 mysql mysql 8192 Apr 19 19:22 mythconverg
drwx------ 2 mysql mysql 4096 Sep 26 2007 zm

/var/run/mysqld:
total 8
drwxr-xr-x 2 mysql root 4096 Apr 18 20:44 .
drwxr-xr-x 15 root root 4096 Apr 19 21:01 ..


I tried starting DB manually using:
Code:
/etc/init.d/mysql stop ; sleep 5 ; /etc/init.d/mysql start

I still get the response
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!


But how do I check the mysql.user table? Can I check it if mysqld failed?

Page 1 of 2 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/