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.
EL
script:
=======
#!/bin/bash
#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
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 " el123@yahoo.com < /home/mysql/check.log
and how executing it:
nohup ./check.sh > check.log &
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.
EL
script:
=======
#!/bin/bash
#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
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 " el123@yahoo.com < /home/mysql/check.log
and how executing it:
nohup ./check.sh > check.log &
In MySQL Server
Share this post:
Accepted Answer
I would recommend you methods below to get back mysql data, but in case they won't be effective, you may apply https://www.repairtoolbox.com/mysqlrepair.html 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.
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.
Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here.
Register Here »