2

I tried to load a .txt file into a MySQL table (via LOCAL DATA), but the files that i'm using, some of them has a accent in their names that are not recognizable by MySQL. When I tried to execute the statement, I receive the following error:

File 'C:\Users...\á.txt' not found (Errcode: 2)

I can avoid this error if I remove all the accents from my .txt files, then the database can locate those files.

Here the statement that I had executed:

LOAD DATA LOCAL INFILE "C:\\Users\\User\\Desktop\\á.txt" INTO TABLE mytable COLUMNS TERMINATED BY ","LINES TERMINATED BY "\r\n"(column_a, column_b, column_c);
heliosk
  • 1,113
  • 3
  • 23
  • 45
  • As a standard practice, I try to limit file names to have only standard alpha-numeric ASCII characters, hyphen, period and underscore (`a-z`, `A-Z`, `0-9`, `.`, `-` and `_`). I recommend you rename those files and take measures to rename any other file that comes to you with "special" characters – Barranka Sep 01 '14 at 17:30
  • I thought about it, but i'm trying to find another way to contour that. – heliosk Sep 01 '14 at 18:22
  • 1
    Take a look at Connection Character Sets and Collations: http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html – A Jolly Geek Sep 01 '14 at 18:33
  • great tip, but it doesn't change the way MySQL behave. btw I'm gonna rename all the files. – heliosk Sep 01 '14 at 19:12

1 Answers1

-1

You question is already answered here:

Loading utf-8 encoded text into MySQL table

You can specify the charset used by your CSV file with the "CHARACTER SET" optional parameter > of LOAD DATA LOCAL INFILE

Your file data will probably be in UTF-8 or ISO-8859-1 format.

Community
  • 1
  • 1
Franz Holzinger
  • 913
  • 10
  • 20
  • MySQL still returns the same message. The data that go into the DB are ok. The problem is, only the character used on the file's name. – heliosk Sep 01 '14 at 18:21
  • Try this (taken from [link](http://wiki.typo3.org/UTF-8_support#SET_NAMES_utf8.3B_and_SET_SESSION_character_set_server.3Dutf8.3B) if your filenames are in UTF-8: `SET NAMES utf8;` `SET SESSION character_set_server=utf8;` You can add commands in a line separated by semicolon ";". – Franz Holzinger Sep 02 '14 at 06:19
  • See [link](http://dev.mysql.com/doc/refman/5.1/de/server-options.html) Add the option `--character-set-filesystem=charset_name` – Franz Holzinger Sep 02 '14 at 06:30