mysqlimport issues "set @@character_set_database=binary" which prevents loading json values
<p>I have been using mysqlimport without problems for a long time, now as mysql 5.7 added json data type support, I'm trying to use mysqlimport with rows containing json data.</p>

<p>Here is an example of a row in csv file that will be imported using mysqlimport:</p>

<pre><code>column_A_value,column_B_value,[{"x":20,"y":"some name"}]
</code></pre>

<p>Notice that the last column type is json. Now when using mysqlimport as the following:</p>

<pre><code>mysqlimport -u user -ppass -h localhost --columns='col_A,col_B,col_C' --local --fields-terminated-by=',' some_db /path/to/products.txt
</code></pre>

<p>I got the following error: <code>Cannot create a JSON value from a string with CHARACTER SET 'binary'., when using table: products</code></p>

<p>However using the generated <code>LOAD DATA IN FILE</code> instead of mysqlimport worked without problems! I opened mysql log and checked the generated LOAD DATA IN FILE command when running mysqlimport, then copied and pasted it, and it worked without problems! I ran something like: </p>

<pre><code>LOAD DATA LOCAL INFILE '/path/to/products.txt'
INTO TABLE products
</code></pre>

<p>And it worked! The only difference is that in the log, when running mysqlimport this line was generated also</p>

<pre><code>Query   /*!40101 set @@character_set_database=binary */
</code></pre>

<p>Then LOAD DATA IN FILE command was generated, so that line is the source of the problem.</p>

<p>So anyway I tried setting character set to utf8, </p>

<pre><code>mysqlimport -u user -ppass -h localhost --columns='col_A,col_B,col_C' --local --fields-terminated-by=',' --default-character-set=utf8 some_db /path/to/products.txt
</code></pre>

<p>but in vain, same error happened.</p>

<p>So any clue how to solve this character set issue please ?</p>