Import CSV file data into MySQL table with phpMyAdmin

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…

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:

image of csv data file with rows of data
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:

interface to phpMyAdmin for importing files
phpMyAdmin import interface…

To complete this import, I follow these steps:

  1. Choose the CSV file to upload via the Choose File button.
  2. Verify the Format drop-down option is set to CSV.
  3. 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.)
  4. Click the Go button.

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

successful upload message in phpMyAdmin
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:

image of csv file with data and column headers
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:

phpMyAdmin interface for uploading CSV files
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.

display of some rows of data in phpMyAdmin
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.


Josh Otwell has a passion to study and grow as a SQL Developer and blogger. Other favorite activities find him with his nose buried in a good book, article, or the Linux command line. Among those, he shares a love of tabletop RPG games, reading fantasy novels, and spending time with his wife and two daughters.

Disclaimer: The examples presented in this post are hypothetical ideas of how to achieve similar types of results. They are not the utmost best solution(s). The majority, if not all, of the examples provided, is performed on a personal development/learning workstation-environment and should not be considered production quality or ready. Your particular goals and needs may vary. Use those practices that best benefit your needs and goals. Opinions are my own.

Advertisements

One thought on “Import CSV file data into MySQL table with phpMyAdmin

Hey thanks for commenting! Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.