DB 테이블 optimize / aleter table 일괄 처리
로빈아빠
본문
#!/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
관련링크
댓글목록
등록된 댓글이 없습니다.