Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL LOAD DATA INFILE issue with special characters

Im having problems with LOAD DATA LOCAL INFILE loading a utf8 file. The Query looks like this:

LOAD DATA LOCAL INFILE 'file.csv' INTO TABLE artikel CHARACTER SET UTF8
FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

But fields with special characters like "Dämmung" will be cut to "D".

SHOW VARIABLES LIKE '%_set_%';

Shows that it's all set to utf8, and I even used notepad++ to make sure the file is utf8.

It would really help, if someone knows advice, it's a huge file and I would like to avoid entering the wrong fields manually :-/

like image 335
user3181103 Avatar asked Jan 27 '14 10:01

user3181103


People also ask

Does varchar allow special characters MySQL?

As the name suggests, varchar means character data that is varying. Also known as Variable Character, it is an indeterminate length string data type. It can hold numbers, letters and special characters.

How do I enable local Infile in MySQL?

For the mysql client, local data loading capability is determined by the default compiled into the MySQL client library. To disable or enable it explicitly, use the --local-infile=0 or --local-infile[=1] option. For the mysqlimport client, local data loading is not used by default.

What is load data infile?

The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. If the LOCAL keyword is specified, the file is read from the client host. If LOCAL is not specified, the file must be located on the server.


1 Answers

I was having the same problem. There is a "hack" that solves this: maitain everything with UTF8. The exception is with the "LOAD DATA LOCAL....". When I use LATIN1 instead of UTF8 it works fine.

like image 172
Gustavo Tarchiani Avatar answered Nov 15 '22 03:11

Gustavo Tarchiani