title: Invalid utf8 character string when importing csv file into MySQL database
body: <p>I use the following command to import data from a .csv file into a MySQL database table like so:</p>
  
  <pre><code>     String loadQuery = "LOAD DATA LOCAL INFILE '" + file + "' INTO TABLE source_data_android_cell  FIELDS TERMINATED BY ','" + "ENCLOSED BY '\"'"
   + " LINES TERMINATED BY '\n'  " + "IGNORE 1 LINES(.....)" +"SET test_date = STR_TO_DATE(@var1, '%d/%m/%Y %k:%i')";
  </code></pre>
  
  <p>However, as one of the columns in the sourcefile contains a really screwy data which is: <code>viva Y31L.RastaMod‰ã¢_Version</code> the program refuses to import the data into MySQL and keeps throwing this error: </p>
  
  <blockquote>
    <p>java.sql.SQLException: Invalid utf8 character string: 'viva
    Y31L.RastaMod'</p>
  </blockquote>
  
  <p>I searched up on this but cant really understand what exactly the error was, other than that the INPUT format of this string "<strong>viva Y31L.RastaMod‰ã¢_Version</strong>" was wrong and didn't fit the utf8 format used in the MySQL database?</p>
  
  <p>However, I already did the following which is <code>SET NAMES UTF8MB4</code> in my MySQL db, since it was suggested in other questions that UTF8MB4 was more flexible in accepting weird characters.</p>
  
  <p>I explored this further by manually inserting that weird data into MySQL database table in the Command Prompt, which worked fine. In fact, the table displayed almost the full entry: <code>viva Y31L.RastaMod?ã¢_Version</code>. But if I ran my program from the IDE the file gets rejected.</p>
  
  <p>Would appreciate any explanations. </p>
  
  <p>Second minor question related to the import process of csv file into mySQL: </p>
  
  <p>I noticed that I couldn't import a copy of the same file into the MySQL database. Errors thrown included that the data was a duplicate. Is that because MySQL rejects duplicate column data? But when I changed all the data of one column leaving the rest the same in that copied file, it gets imported correctly. Why is that so? </p>