centos下mysql腳本批量執行腳本
host="192.168.1.203"
user="root"
password="123456"
echo "start"
for file in init/*/*/mysql/year_init.sql
do
if [ -f "$file" ]
then echo "$file excute"
mysql -h $host -u$user -p"$password" -D 2022 < $file
fi
done
for file in init/*/*/mysql/app_init.sql
do
if [ -f "$file" ]
then echo "$file excute"
mysql -h $host -u$user -p"$password" -D app < $file
fi
done
echo "end"
腳本缺陷:依賴本地的mysql。
解決方案:如果使用python的話就沒有這個問題了,這種方案相對缺點的是還需要安裝python。

浙公網安備 33010602011771號