I was given access to an existing instance of MySQL via phpMyAdmin. My task was to import a CSV file using the import feature on phpMyAdmin. First, I went to the the main phpMyAdmin page. Next, I clicked on the database instance that I am interested. Then, I click on the table that I want to import my data and click on Import button. On the import form, I click Browse button to choose the CSV file on my local hard drive. Since my CSV file uses “|” to separate each fields and “\n” to separate each records, I chose the following options:
- Chose CSV using LOAD DATA
- Fields terminated by: |
- Fields enclosed by: [remove default value and leave it blank]
- Fields escaped by: [remove default value and leave it blank]
- Leave everything else to default value.
Finally, I clicked the Go button. This resulted the following SQL query. Note, I renamed values that are specific to my environment. So this is just for your reference only.
LOAD DATA LOCAL INFILE 'input_file' INTO TABLE `tablename` FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'# Affected rows: 1