Site5 - Built For Designers & Developers MENU

MySql tables Corruption Checking

[2 Grey Star Level]

Hi Gurus,

I want to create a script to check the status of the mysql db tables, have already done it, my script is creating a simple file with all the status info, and sending me an email too.

But what I’m looking for;
I just want to get an email, when the status is not equal to OK … that’s it.

Can any one help, thanks, best regards.


#Set Credentials
export HOST=`hostname`
export USER=abcd
export PASSWORD=abcd
export DATABASE=abcd
export FILE=/home/mysql/$DATABASE_check.txt
## checking process
echo checking process of $DATABASE@$HOST
echo START_TIME “>>>>>> `date +%m_%d_%Y:%H:%M:%S`”
mysqlcheck –user=$USER –password=$PASSWORD $DATABASE
echo END_TIME “>>>>>> `date +%m_%d_%Y:%H:%M:%S`”
mail -s “MySql Tables check – abcd@abcd ” check.log &

Answer #1


A simple way to do this would be to set a second script to run on a cron, that greps /home/mysql/$DATABASE_check.txt and emails you if certain keywords are found.

Answers Answered By: jdavey [359 Blue Star Level]

Answer #2

I would recommend you methods below to get back mysql data, but in case they won’t be effective, you may apply Repair Toolbox for MySQL

Method 1.
Step 1. Log into mysql as administrator
mysql -uroot -p
Step 2. Select the database containing the corrupted table, i.e., ‘use {database name};’
mysql> use {database name};
Step 3. Show tables your corrupted table should be listed
mysql> show tables;
Step 4. Repair table
mysql> repair table {bad_table_name};

Method 2.
Step 1. Login to your MySQL server using Secure Shell (SSH).
Step 2. Repairing MyISAM mySQL Tables/Databases.
cd /var/lib/mysql/DBNAME
myisamchk -r -f tables.MYI
Please note that MyISAM is a default storage engine of MySQL, unless you change it. Mostly MyISAM is set as default engine to check and repair all the tables in the mysql database.

Answers Answered By: erkanyavuz [2 Grey Star Level]

Answer this Question

You must be Logged In to post an Answer.

Not a member yet? Sign Up Now »

Money Back Guarantees
Click to verify BBB accreditation and to see a BBB report.