Skip to content

Instantly share code, notes, and snippets.

@sanampatel
Last active July 24, 2017 11:20
Show Gist options
  • Save sanampatel/7c8f5434f0abd8b784634eb52d8fee19 to your computer and use it in GitHub Desktop.
Save sanampatel/7c8f5434f0abd8b784634eb52d8fee19 to your computer and use it in GitHub Desktop.
Import CSV file into MySQL
LOAD DATA LOCAL INFILE '<file path here>' INTO TABLE <table name here>
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(col1, col2, col3, col4, col5...);
/*
Also add below line to skip first header line from the CSV file
IGNORE 1 LINES
From database tables
(col1, col2, col3, col4, col5...);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment