knoppmyth.net Forum Index knoppmyth.net
The home of KnoppMyth.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Repairing broken MySQL tables
Goto page Previous  1, 2
 
Post new topic   Reply to topic    knoppmyth.net Forum Index -> Hints & Tips
View previous topic :: View next topic  
Author Message
tjc



Joined: 25 Mar 2004
Posts: 9120
Location: Arlington, MA

PostPosted: Wed Dec 12, 2007 5:30 pm    Post subject: Reply with quote

Successfully completing the steps described above will ensure that the DB tables are self consistent, but not that they contain all the necessary data for your recordings. The following thread contains directions for other things you may to do to complete the recovery after doing DB repairs. http://mysettopbox.tv/phpBB2/viewtopic.php?t=14002&highlight=mythcommflag
_________________
KnoppMyth Wiki
Troubleshooting guides
R5.5 Hints
Back to top
View user's profile Send private message
datobin1



Joined: 21 Dec 2005
Posts: 143
Location: Charlotte NC USA

PostPosted: Mon Feb 04, 2008 6:57 am    Post subject: Reply with quote

I had a problem last night with my program table that I was not able to correct with the normal methods but, came up with another solution and wanted to share it incase anyone has a similar problem.

Symptoms of the problem;
mythfrontend works fine but there is no guide data/ show listings/ channel info.
if you try to look at the mythconverg database through webmin it will tell you the program table is corrupt.


Results from an attempt to repair the table;
When trying all the different methods of repair the result with an error 5

If I shutdown the mysql and tried to copy the tables file program.MYI it would return an error because the file was corrupt..... This is when I new I was in trouble.

How I fixed the table

Code:

#su
#mysql
mysql> TRUNCATE TABLE program;
mysql>exit
#mythfilldatabase


After mythfilldatabase completed all was good.

This method only works on a table that can be repopulated and where the data file is corrupt but the table schema is in tact.

The truncate table command deletes all the data in the table but leave the table structure in tact.
Back to top
View user's profile Send private message
BluesBrian



Joined: 28 Jul 2005
Posts: 224
Location: SF East Bay, CA

PostPosted: Sat Feb 23, 2008 11:32 pm    Post subject: Reply with quote

yet another system crash, and more filesystem fixes..

this time, mysql won't start, and I get

Quote:
/var/log/syslog
mysqld_safe[3918]: started
mysqld[3921]: 080223 23:07:40 InnoDB: Started; log sequence number 0 43665
mysqld[3921]: 080223 23:07:40 [ERROR] /usr/sbin/mysqld: Incorrect information in file: './mysql/host.frm'
mysqld[3921]: 080223 23:07:40 [ERROR] /usr/sbin/mysqld: Incorrect information in file: './mysql/host.frm'
mysqld[3921]: 080223 23:07:40 [ERROR] Fatal error: Can't open and lock privilege tables:
Incorrect information in file: './mysql/host.frm'
mysqld_safe[3932]: ended

/etc/init.d/mysql[4067]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping'
resulted in
/etc/init.d/mysql[4067]: ^G/usr/bin/mysqladmin: connect to server at 'localhost' failed
/etc/init.d/mysql[4067]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
/etc/init.d/mysql[4067]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
/etc/init.d/mysql[4067]


This seems to indicate that /var/lib/mysql/mysql/host.frm got corrupted. Does anyone have a suggestion on how to fix this file? (This file is not readable on my working machine!)
Thanks!
_________________
// Brian - Hardware:
ASUS P5P800 - P4 3Ghz, 500 GB PATA HD
ASUS P5K-V - P4 Core2 Duo, 500 GB SATA HD
Hauppauge PVR-350, IR Blaster, Comcast Digital Cable
http://tech.groups.yahoo.com/group/KnoppMyth/
KnoppMyth R5F27 >> R5.5
Back to top
View user's profile Send private message
Too Many Secrets



Joined: 20 Oct 2006
Posts: 847
Location: LA, CA

PostPosted: Wed Oct 21, 2009 3:05 pm    Post subject: Reply with quote

In R6 this needs to be changed a bit. This worked for me.

Code:

cd /data/srv/mysql/mythconverg
sv stop mythbackend
sv stop mysql
myisamchk *.MYI >> mythconverg_check.log

To repair
Code:

myisamchk -r <table name here>

Then to restart
Code:

sv start mysql
sv start mythbackend
Back to top
View user's profile Send private message Send e-mail
tjc



Joined: 25 Mar 2004
Posts: 9120
Location: Arlington, MA

PostPosted: Wed Oct 21, 2009 5:59 pm    Post subject: Reply with quote

This version of optimize_db.sh should work. I thought it had been published here before, but apparently not... :-/

Code:
#!/bin/bash

. /usr/LH/bin/backupcommon || {
    echo 1>&2 "Can not load common settings!"
    exit 1
}

must_be_root

# Prevent mythshutdown from shutting down the system in the middle...
lock_myth

# The database needs to be idle when we do this...
# Having it auto restarted would also be "bad". ;-)
stop_mythbackend
stop_mysqld

cd $DATABASE_DIR || fatal "Could not cd to $DATABASE_DIR"

for tbl in *.MYI ; do
    # If the fast way fails fall back on the old slow way.
    $MYISAMCHK --recover $tbl || {
        echo "Fast recovery of $tbl failed, attempting slower safe recovery..."
        $MYISAMCHK --safe-recover $tbl ||
            fatal "Even safe recovery of $tbl failed! Aborting!"
    }
    $MYISAMCHK --analyze $tbl
done

# Resatart the servers in the right order...
start_mysqld
start_mythbackend

# Unlock the system again...
unlock_myth

_________________
KnoppMyth Wiki
Troubleshooting guides
R5.5 Hints
Back to top
View user's profile Send private message
Girkers



Joined: 22 Mar 2005
Posts: 1193
Location: Brisbane, Queensland, Australia

PostPosted: Wed Oct 21, 2009 6:59 pm    Post subject: Reply with quote

tjc any chance of getting the updated file put in the Arch (LinHES) repositories to make it easier to get?
_________________
Girkers

www.gkcomputerservices.com
Back to top
View user's profile Send private message Send e-mail MSN Messenger
tjc



Joined: 25 Mar 2004
Posts: 9120
Location: Arlington, MA

PostPosted: Thu Oct 22, 2009 7:19 pm    Post subject: Reply with quote

A week ago I thought it was already there, but apparently it never got added. Maybe this weekend I'll get some breathing room and be able to do it.
_________________
KnoppMyth Wiki
Troubleshooting guides
R5.5 Hints
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    knoppmyth.net Forum Index -> Hints & Tips All times are GMT - 8 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group