CSV to MySQL large files?

Discussion in 'MySQL' started by mnymkr, Jun 25, 2007.

  1. #1
    So I was wondering if some gurus could tell me the best way to upload a 16M csv to mysql.
     
    mnymkr, Jun 25, 2007 IP
  2. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    connect to your mysql server using ssh, and then run the following code:
    LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name
      FIELDS TERMINATED BY ',' ENCLOSED BY '"'
      LINES TERMINATED BY '\n';
    Code (markup):
    you might have to upload the file to your server first, but i'm not sure.
    To connect to the mysql server via ssh, use the following command:
    mysql -h host_here -u username -p database_name
    Code (markup):
    it will ask you to enter your password once you press enter

    i found it on the mysql manual:
    http://dev.mysql.com/doc/refman/5.0/en/load-data.html#id3272292 (still can't post live urls :()
     
    UnrealEd, Jun 25, 2007 IP
  3. mnymkr

    mnymkr Well-Known Member

    Messages:
    2,328
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    120
    #3
    thats cool. although i don't think they guy i am making this for would know what to do.

    there is always navicat but it costs

    i was hoping maybe there was a script that did a nice job of it....
     
    mnymkr, Jun 25, 2007 IP
  4. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i read somewhere that phpMyAdmin has a function to import csv files. I've never used it before, so i don't know if it's gonna work for 16Mb files

    wait: i just checked on my phpMyAdmin: in the import tab, there's a radiobutton named CSV, check that, and you'll see the settings that you have to change

    You can use Oracle's SQL developer: it's free, and allows you to import CSV files easily:
    http://www.oracle.com/technology/products/database/sql_developer/index.html
     
    UnrealEd, Jun 25, 2007 IP
  5. mnymkr

    mnymkr Well-Known Member

    Messages:
    2,328
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    120
    #5
    yeah it doesn't support anything that big , that was first thing i tried.
     
    mnymkr, Jun 25, 2007 IP
  6. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #6
    PHPMyAdmin supports whatever you allow PHP to support.

    You just need to edit the PHP INI file to allow more memory to be used, larger post size and larger file upload size.

    My PHPMyAdmin installations support importing up to 256MB files.
     
    KalvinB, Jun 26, 2007 IP