사이트 내 전체검색
DB 테이블 optimize / aleter table 일괄 처리
로빈아빠
https://cmd.kr/server/1113 URL이 복사되었습니다.

본문

#!/bin/bash

 
if [ $# -lt 2 ]; then
        echo "You must specify database host"
        echo "Eg. script.sh MY_DATABSE 192.168.10.1"
        exit
fi
 
db="$1"
host="$2"
user="root"
 
stty -echo
read -p "Enter MySQL's Admin password: " password
stty echo
 
mysql -u $user --password=$password -h $host --batch --skip-column-names $db -e "SHOW TABLES" |
while read table; do
        echo $table &&
        time mysql -u $user --password=$password -h $host $db -e "ALTER TABLE $table ENGINE=INNODB"

done 

 

=====================================================

 

 

#!/bin/bash db="DB명" host="localhost" user="root" password="DB암호" mysql -u $user --password=$password -h $host --batch --skip-column-names $db -e "SHOW TABLES" | while read table; do echo ALTER TABLE $table && time mysql -u $user --password=$password -h $host $db -e "ALTER TABLE $table ENGINE=INNODB" done mysql -u $user --password=$password -h $host --batch --skip-column-names $db -e "SHOW TABLES" | while read table; do echo optimize TABLE $table && time mysql -u $user --password=$password -h $host $db -e "optimize TABLE $table" done

 

 

 

 

댓글목록

등록된 댓글이 없습니다.

1,139 (2/23P)

Search

Copyright © Cmd 명령어 18.117.103.185