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…
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:
Clicking the Import tab at the top of the phpMyAdmin interface, moves to this screen, containing several import options:
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.
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:
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:
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.
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.
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.