Q:

Is mysql load file data charset handling environment dependent?

I called DATA INFILE from java.sql.Statement.executeUpdate(String sql) to load UTF-8 CSV file into table.
When I use
LOAD DATA INFILE '/var/lib/mysql-files/upload/utf8table.csv' INTO TABLE temp.utf8table CHARACTER SET utf8 FIELDS TERMINATED BY ';'  LINES TERMINATED BY '\r\n' (@vC1, @vC2) set C1=@vC1, C2=nullif(@vC2,'');

, without specifying CHARACTER SET utf8, non ASCII characters were corrupted.  But the same query imported all characters correctly when was executed in Mysql Workbench.   Query with charset specified works well in both cases. What can be the difference in the execution environments that leaded to such behavior?

A:

According to the docs:

The server uses the character set indicated by the character_set_database system variable to interpret the information in the file. SET NAMES and the setting of character_set_client do not affect interpretation of input. If the contents of the input file use a character set that differs from the default, it is usually preferable to specify the character set of the file by using the CHARACTER SET clause. A character set of binary specifies “no conversion.”

See also sysvar_character_set_client. The default is latin1 if not specified.

