How to Import .sql file via PHP?

Discussion in 'PHP' started by subfor, Sep 5, 2009.

  1. #1
    Hello,

    I would like to ask, what command to use in order to upload .sql file to the database using php.

    Thank You in advance
     
    subfor, Sep 5, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Bohra, Sep 5, 2009 IP
  3. subfor

    subfor Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I am going to use a cronjob to run my php script, so bigdump is not proper for me
     
    subfor, Sep 5, 2009 IP
  4. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #4
    Well bigdump uses get to import a file ... its in such a format bigdump.php?start=1&fn=wrdp1.sql.gz so u can call it using cron

    Otherwise try this

    if (mysql_query("SOURCE file.sql")) {
    echo "success";
    }
     
    Bohra, Sep 5, 2009 IP
  5. subfor

    subfor Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Bohra. Great tip with bigdump :) Everything worked like a sharm
     
    subfor, Sep 5, 2009 IP
  6. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #6
    Kool Glad i could help
     
    Bohra, Sep 5, 2009 IP