mysql load data scripts - save the output

时间:2015-09-29 00:45:22

标签: mysql

When running a mysql load data command from the console their is output that tells you the number of records loaded and the time. Here is an example:

mysql> LOAD DATA INFILE '/tmp/RESPONSE.txt' replace INTO TABLE db1.RESPONSE FIELDS TERMINATED BY '|'
-> ignore 2 lines;
Query OK, 3088090 rows affected, 65535 warnings (2 min 40.14 sec)
Records: 3088090  Deleted: 0  Skipped: 0  Warnings: 661200

I have many tables that I load data into each day and I wanted to create a script to do it and then review the output. The issue that I run into is that when I load the data using a script like this:

mysql <loadscript > loadresults

The file load results is always empty.

Is there anyway to capture the same output that you would get on the console in a file?

2 个答案:

答案 0 :(得分:0)

我在Windows中遇到了同样烦人的问题。我能找到的唯一解决方案是使用mysqlimport,如下所示:

mysqlimport -p  --fields-terminated-by="," --lines-terminated-by="\r\n" ^
--fields-optionally-enclosed-by="""" --local ^   
myDatabase myTable.txt

答案 1 :(得分:0)

我遇到了与原始问题相同的问题,并且(this post)提示了一个解决方案:使用“-vv”选项启用mysql的双重详细信息。