Import CSV file data into MySQL table with phpMyAdmin
By: Joshua Otwell
Tags: PHP, Database, MySQL, Technical Writing, Web Development

In the blog post MySQL CREATE TABLE in PHPMyAdmin — with examples, I covered using phpMyAdmin’s visual interface to complete CREATE TABLE tasks. I also mentioned uploading CSV data files to a table using phpMyAdmin in an upcoming post. In this follow-up post, we accomplish uploading CSV files that both do and do not have the column names present in the first row. Continue reading to see the examples…

Photo by Cytonn Photography on Unsplash

Self-Promotion:

If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like!

Uploading CSV data to a MySQL database table couldn’t be easier than it is using phpMyAdmin. While I won’t cover each and every option available, after reading this post, you will know how to complete this operation. Let’s get started!

Basic CSV upload with no column header row.

Suppose you have a CSV data file with no columns names in the first row, similar to this one in which I recorded my walking stats (E.g., distance, date, time, calories burned, etc…) for the month of January 2019:

CSV file with data. No column names in first row…

Clicking the Import tab at the top of the phpMyAdmin interface, moves to this screen, containing several import options:

phpMyAdmin import interface…

To complete this import, I follow these steps:

Choose the CSV file to upload via the Choose File button. Verify the Format drop-down option is set to CSV. List out all the table column names in the Column names: section. (I feel you can likely skip this portion since no table column names are present in the CSV data file’s first row. However, I still include them anyways.) Click the Go button.

Upon successful import, an information box with details — similar to the one below — is presented in the interface.

Successful CSV upload message in phpMyAdmin.

Basic CSV upload with column header row.

There is not much difference between importing a CSV file that contains a column header row and one that does not. In all actuality, only one section is different.

For this example import, I have this CSV file that does have the first row of column names:

CSV file with column row names.

As shown in this image, the difference is in choosing a ‘1’ (in this instance at least) in the Skip this number of queries (for SQL) starting from the first one: number selector box. This is essentially directing the import to skip the first row — which has the column names:

Uploading CSV data with phpMyAdmin, skipping the header row…

Keeping all other settings identical to those from the first example, clicking Go executes the import.

The below image captures a sample of the data set that I successfully uploaded via phpMyAdmin from a CSV file, both with and without column header names.

January’s data displayed in phpMyAdmin

As you can see, phpMyAdmin provides an intuitive interface to visually work with MySQL databases, making tasks like importing CSV files quite simple. Thanks for reading!

Like what you have read? See anything incorrect? Please comment below and thanks for reading!!!

A Call To Action!

Thank you for taking the time to read this post. I truly hope you discovered something interesting and enlightening. Please share your findings here, with someone else you know who would get the same value out of it as well.

Visit the Portfolio-Projects page to see blog post/technical writing I have completed for clients.

Have I mentioned how much I love a cup of coffee?!?!

To receive email notifications (Never Spam) from this blog (“Digital Owl’s Prose”) for the latest blog posts as they are published, please subscribe (of your own volition) by clicking the ‘Click To Subscribe!’ button in the sidebar on the homepage! (Feel free at any time to review the Digital Owl’s Prose Privacy Policy Page for any questions you may have about: email updates, opt-in, opt-out, contact forms, etc…)

Be sure and visit the “Best Of” page for a collection of my best blog posts.