How to check and fix mysql database tables _ MySQL

Source: Internet
Author: User
Check and fix the specific mysql database table method bitsCN. com01
#! /Bin/sh
02
# Code by scpman
03
# Function: check and fix mysql database tables
04
# Add the script to the timer. when the script is executed, it will read the database, list all the tables to be repaired, timing them, and start fixing.
05
# The damaged table is recorded in the repair process. after the repair is completed, the damaged table is sent to an email.
06
Fix_logs = '/tmp/fix. log'
07
User =''
08
Pass =''
09
Check_fix ()
10
{
11
Dblist = '/usr/bin/find/usr/dlm_db/mysql/-type d | grep-vE "logs | _ [1-9] | * bak | test" | sed -e "s #/usr/dlm_db/mysql/# g "'
12
Echo start 'date'> $ fix_logs
13
For dbname in $ dblist
14
Do
15
Echo $ dbname
16
For tb_name in '/usr/bin/find/usr/dlm_db/mysql/$ dbname-type f | awk-f'/''{print $ NF}' | awk-F '. ''{print $1} '| sort-
17
U'
18
Do
19
Mysql-u $ user-p $ pass $ dbname < > $ Fix_logs
20
Check table $ tb_name;
21
Repair table $ tb_name;
22
FFF
23
Done
24
Done
25
Echo 'date' done> $ fix_logs
26
}
27
Send_logs ()
28
{
29
Msgip = 10.0.7.44
30
IP = 'cat/etc/rc. conf | grep-E "ifconfig _ [em1 | bce1]" | awk '{print "IP:" $2}' | sed-n 1 P'
31
Fix_info = 'grep-rE "Error | start | done" $ fix_logs'
32
/Usr/bin/logger-p local1.info-h $ msgip "the services: $ IP mysql_table_fix_info: $ fix_info"
33
}
34
Check_fix
35
Send_logsbitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.