Friday, April 12, 2019

MySQL: find out what were the warnings of the mysqlimport command


The output of mysqlimport can show there were some warnings during the import.

$ mysqlimport --local MyDatabase MyTable.txt
MyDatabase.MyTable: Records: 2  Deleted: 0  Skipped: 0  Warnings:2


However, it does not tell what those warnings were.

You may run the import again with another MySQL statement LOAD DATA to see what might be the problem.

However, the new warnings may be different because the data has already been imported and the 2nd import may generate the other warnings for duplicate records. If that happens, we could first manually remove those records from the table beforehand.

The command to import data with warnings shown is:

$ mysql -u mydbusername -p MyDatabase --execute="LOAD DATA LOCAL INFILE 'MyTable.txt' INTO TABLE MyTable FIELDS TERMINATED BY ',' (MyColumn1, MyColumn2, MyColumn3); SHOW WARNINGS"

Replace every parameters starts with "My..." to your actual database/table/column names.

No comments:

 
Get This <