天天看點

shell腳本中怎樣同時執行多個.sql檔案,并把結果寫入檔案中(轉)

轉載:http://joewalker.iteye.com/blog/408879

指令行下具體用法如下:

mysqldump -u用戶名 -p密碼 -d 資料庫名 表名 > 腳本名;

導出整個資料庫結構和資料

mysqldump -h localhost -uroot -p123456 database > dump.sql

導出單個資料表結構和資料

mysqldump -h localhost -uroot -p123456 database table > dump.sql

導出整個資料庫結構(不包含資料)

mysqldump -h localhost -uroot -p123456 -d database > dump.sql

導出單個資料表結構(不包含資料)

mysqldump -h localhost -uroot -p123456 -d database table > dump.sql

http://www.cnblogs.com/wangkongming/p/3648476.html

 more import.sh

#!/bin/bash

time=$(date +%Y%m%d-%H%M%S)

filename="result-"${time}.log

echo $filename

echo $(date)" begin....">$filename

mysql -A -h localhost -u root -p123 test<$1 >>$filename 2>&1

echo $(date)" success! ">>$filename

第一版:

第二版:

第三版:

http://bbs.chinaunix.net/thread-4166340-1-1.html

用途:将遠端伺服器的資料庫拷到本地。

代碼代碼如下:

mysqldump -h '114.212.111.123' -uROSE -pxxxooo --opt --compress ITSM --skip-lock-tables | mysql -h localhost -uroot -proot ITSMC

http://www.shangxueba.com/jingyan/1942037.html