How to import large CSV file to your Mysql or PHPMYADMIN

Wahyu Raja Butar-Butar Reply 15:24
First you must create a file. with everything. i assume my filename is bigdump.php. and write this code:

<?php
mysql_connect('servername','username','password');

mysql_select_db('databasename');

$sql = "LOAD DATA LOCAL

INFILE 'data.csv'

INTO TABLE data

FIELDS

       TERMINATED BY ','

       OPTIONALLY ENCLOSED BY '\"'";

$insert = mysql_query($sql);

if($insert)

  echo 'success';

else

  die('error : ' . mysql_error());

?>

and now put in htdocs. and dont forget to move your csv file to htdocs too. and run it. TARAAA.. you got you want :)

Related Posts

phpmyadmin 316677813051008134
Comments
0 Comments
Facebook Comments by Media Blogger

Post a Comment

Search

Google+ Followers

Popular Posts

Translate