How to repair mysql database

Users tips and ideas

Moderators: FlorianB, Pascal, bourgeois, mentor

EasyPrey
Posts: 8
Joined: Thu Jun 07, 2007 8:13 pm

How to repair mysql database

Postby EasyPrey » Wed May 14, 2008 3:45 pm

I have had a number of mysql database corrupt (on a multi-site installation). Most of my corruptions were in mc_spool database. If you run this script, I think you may be surprised at how many tables on your system needs to be repaired.

Here is the script to repair mysql database on mailcleaner system:

Code: Select all

#!/bin/bash

# This script will safely repair the master and slave database.

# You should not use "myisamchk", without UNDERSTANDING what it does.
# Caveat Emptor!
# http://dev.mysql.com/doc/refman/4.1/en/myisamchk.html

REPAIR_CMD="/usr/mysql4/bin/myisamchk --force --fast --update-state \
  --key_buffer_size=64M --sort_buffer_size=64M \
  --read_buffer_size=1M --write_buffer_size=1M"

/etc/init.d/mailcleaner stop
iptables -A INPUT -p tcp --dport smtp -j REJECT

$REPAIR_CMD /var/mailcleaner/spool/mysql_master/mysql/*.MYI
$REPAIR_CMD /var/mailcleaner/spool/mysql_master/mc_spool/*.MYI
$REPAIR_CMD /var/mailcleaner/spool/mysql_master/mc_config/*.MYI

$REPAIR_CMD /var/mailcleaner/spool/mysql_slave/mysql/*.MYI
$REPAIR_CMD /var/mailcleaner/spool/mysql_slave/mc_spool/*.MYI
$REPAIR_CMD /var/mailcleaner/spool/mysql_slave/mc_config/*.MYI

iptables -F
/etc/init.d/mailcleaner start


I wrote this script once my quarantine summaries stopped being sent due to corrupted tables.

Hope this helps.
ptlinva
Posts: 17
Joined: Sat Nov 11, 2006 9:09 am
Contact:

Postby ptlinva » Fri Jun 06, 2008 4:04 am

I was able to succesfully copy this file over to the mailcleaner.

I saved the file as scripts.sh. I ran it as 'sh scripts.sh'.

I got a bunch of permission denied errors when trying to modify the mysql tables.

Any suggestions/comments would be greatly appreciated.
-Paul
EasyPrey
Posts: 8
Joined: Thu Jun 07, 2007 8:13 pm

Postby EasyPrey » Mon Jun 09, 2008 8:06 pm

Paul,

If you are running this as root. You should not get any permission denied.

Should running this as root not resolve this. Please post the actual error messages produced by this script.
informatica
Posts: 18
Joined: Mon May 10, 2010 12:25 pm
How did you hear about Mailcleaner: google

Re: How to repair mysql database

Postby informatica » Thu Aug 05, 2010 12:37 pm

nice, with this script i fixed all tables fast.

just change this line with the beta 3:

Code: Select all

REPAIR_CMD="/opt/mysql5/bin/myisamchk --force --fast --update-state \
directict
Posts: 75
Joined: Tue Jul 12, 2011 6:04 pm
How did you hear about Mailcleaner: google

Re: How to repair mysql database

Postby directict » Tue Aug 23, 2011 10:03 am

im getting:
./repairdb.sh: line 16: /usr/mysql4/bin/myisamchk: No such file or directory
./repairdb.sh: line 17: /usr/mysql4/bin/myisamchk: No such file or directory
./repairdb.sh: line 18: /usr/mysql4/bin/myisamchk: No such file or directory
./repairdb.sh: line 20: /usr/mysql4/bin/myisamchk: No such file or directory
./repairdb.sh: line 21: /usr/mysql4/bin/myisamchk: No such file or directory
./repairdb.sh: line 22: /usr/mysql4/bin/myisamchk: No such file or directory
uncltom
Posts: 495
Joined: Tue Aug 26, 2008 3:01 am
How did you hear about Mailcleaner: I dont remember probably google?
Location: Spokane, WA

Re: How to repair mysql database

Postby uncltom » Wed Aug 24, 2011 2:21 am

See post above yours.

Return to “Tips”

Who is online

Users browsing this forum: No registered users and 2 guests