Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2002
    Posts
    3

    Smile Unanswered: importing .csv files into mysql

    having difficulty with importing a text file into mysql... I have set up all the fields to correspond with my database, using phpMyAdmin, but when I use the insert text file and locate my file on my computer it returns the following message.

    LOAD DATA LOCAL INFILE 'C:\apache\php\php7113.TMP' INTO TABLE basetable FIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '\\' LINES TERMINATED BY '\n'
    MySQL said: File 'c:apachephpphp7113.tmp' not found (Errcode: 2)

    the file directory I am trying to upload is replaced with the above directory...

    Im pretty new to all this stuff, so I may be missing the blatantly obvious, but any help would be appreciated.

  2. #2
    Join Date
    Jul 2001
    Location
    NC
    Posts
    102
    Reggie -

    If you look at the directories listed in your mysql ini file, mine is found at c:\windows\my.ini, you'll note that the slashes are "reversed", so try ... INFILE 'C:/apache/php/php7113.TMP' INTO TABLE ...

  3. #3
    Join Date
    Dec 2002
    Posts
    3

    thank you

    many thanks for your reply,
    I tried inserting the forward slashes, but to no avail. I am wondering if the location of the file to be uploaded is relevant, as it seems to me that mysql is unable to locate the file in its directory.
    Is it possible that I would need to load the file into a specific directory that would be related to the localhost apache server...
    apologies if that doesn't make any sense, but I am out of my depth really.
    again, thanks for taking the time to reply to my post.

  4. #4
    Join Date
    Jul 2001
    Location
    NC
    Posts
    102
    try moving csv file to the data directory and changing "load data local infile" to "load data infile". I think that will do it.

  5. #5
    Join Date
    Dec 2002
    Posts
    3

    Talking Success!

    Originally posted by vududoc
    try moving csv file to the data directory and changing "load data local infile" to "load data infile". I think that will do it.
    took off the local bit, inserted the exact location of the file on my PC to be uploaded, used /, rather than \, ran the new SQL query in phpMYadmin, and bingo bango, lots of lovely data in all the right places....

    many thanks for taking the time and trouble to post, your help is VERY much appreciated...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •