900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > shell脚本中怎样同时执行多个.sql文件 并把结果写入文件中(转)

shell脚本中怎样同时执行多个.sql文件 并把结果写入文件中(转)

时间:2023-12-02 02:15:17

相关推荐

shell脚本中怎样同时执行多个.sql文件 并把结果写入文件中(转)

转载:/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

/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

第一版:

#!/bin/bashUSER="root"DATABASE="test"TABLE="user"mysql -u $USER $DATABASE --html --default-character-set=utf8 < one.sql > /tmp/check.htmlmysql -u $USER $DATABASE --html --default-character-set=utf8 < two.sql >> /tmp/check.html

第二版:

#!/bin/bashUSER="root"DATABASE="test"TABLE="user"#:>/tmp/check.htmlfor i in one.sql two.sql three.sql; domysql -u $USER $DATABASE --html --default-character-set=utf8 < $i >> /tmp/check.htmldone

第三版:

#!/bin/bashUSER="root"DATABASE="test"TABLE="user"for i in `ls *.sql`; domysql -u $USER $DATABASE --html --default-character-set=utf8 < $i >> /tmp/check.htmldone

/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

/jingyan/1942037.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。