MySQL batch Modify Table Storage Engine

Source: Internet
Author: User

Parameter List:

[DB] [db_host] [db_user] [db_passwd]

 

 

#! /Bin/bash

If [$1]
Then
Echo database $1;
Else
Echo 'backup database tables to gzip files sh bak_db_table.sh DB [db_host] [db_user] [db_passwd] '; exit;
Fi

[$1] & DB = $1
[$2] & DBH = $2
[$3] & dbu = $3
[$4] & DBP = $4

[$ DBH] & DBH = "-h" $ DBH
[$ Dbu] & dbu = "-U" $ dbu
[$ DBP] & DBP = "-P" $ DBP

List = ('echo show tables |/opt/modules/MySQL/bin/MySQL $ DBH $ dbu $ DBP $ db ')

Tbcount = $ ($ {# list [@]}-2 ))

If [$ tbcount =-2] # hg9 {1 + 2; 4ftz; _ j}>]? BA, = SJ '0/
Then
Echo empty tables in $ db or connent failed! ; Exit 1;
Fi
Echo table count: $ tbcount

 

For (I = 1; I <($ tbcount + 1); I ++ ))
Do
Table =$ {list [$ I]}
Echo alter table $ db. $ table
Echo "alter table $ db. $ table type = MyISAM;" |/opt/modules/MySQL/bin/MySQL $ DBH $ dbu $ DBP;
# Sleep 10
Done

Related Article

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.