Using
phpMyAdmin Batch Insert data into MySQL
Assume you finished the lessons:
Prepare data file
Sometime, you have
formatted data file. Assume they are semicolon delimited. For example,
we have following contact information in a data file( semicolon delimited)
and plan to insert it into our "Contact" table:
| Harry |
555-234-5890 |
| Jerry |
666-123-5678 |
| Potter |
888-234-1234 |
In the data file, the above data may look like
Harry;555-234-5890
Jerry;666-123-5678
Potter;888-234-1234
Insert data into MySQL
Launch your phpMyAdmin in browser. In the left
side you see the a drop down menu, named "Databases",
click on the drop down menu and select your database, like the
following image:
The number in () shows how many tables in that database. We need
insert into database phonebook. So we select it. Left side window
will change like following:
Click on table: contact. You will see a text line "Insert
data from a text file into the table" on the bottom of the right
panel. Click on it. You will see the right panel change to following
image:

Click on "Browse" button to locate your data file.
In "Fields terminated
by", we accept the default ";" because our
data file is semicolon delimited. If you use tab delimited files,
input "\t" instead of ";".
In "Fields enclosed by", we clear the default value and
leave it empty since we didn't enclose our data.
There is no special
character in our data file, so we set "Fields
escaped by" empty.
We accept the default value "Lines terminated
by" because our data
is one record per line.
Leave "Column names" empty since our insert
value used all 2 columns in table "contact": name and phonenumber.
Then click on "Submit" button.
You will see a message in the updated panel saying
"Inserted
rows: 3 (Query took 0.0007 sec)".
Browser data in MySQL
Now, you may check you insert by clicking on "Browse" tab.
You will see the following image:
Congratulations. You just batch-insert your data into MySQL. |