Comma-separated values files – also known as CSV’s – are one of the most recognized and used data storage/exchange formats. Whether a CSV is the best choice or not remains to be seen. For some data, a CSV is fine. For others, not so much. At some point, chances are someone will need data from a MySQL database in CSV format. That’s not at all difficult and there are several ways to do that. What if you are working in the phpMyAdmin interface? Can you export CSV’s from the phpMyAdmin environment? You sure can. Continue reading to see simple examples of exporting MySQL table data to a CSV file using phpMyAdmin…
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!
Need to import CSV data into a MySQL table using phpMyAdmin? Not sure how to do it? I wrote Import CSV file data into MySQL table with phpMyAdmin just for you! Be sure and check it out.
I have this table of data, storing different brands of shoes I wear on my many walks and hikes. (Yes, I am finicky about my footwear.)
Suppose I want to export this table’s data to a CSV file using phpMyAdmin?
Here are the steps:
- Click the Export tab.
- Under the Export method: section select the Quick – display only the minimal options radio circle.
- In the Format: section, choose CSV from the drop-down.
- In the Rows: section, click the Dump all rows radio circle (if it is not already selected by default).
- Finally, click the Go button and the table rows will be exported to a CSV.
Having followed the above steps, your screen should look similar to mine captured in the picture below:
The below image captures the fruit of our labor, a CSV file with the exported table data:
You may have noticed that the CSV file does not contain a first row of column names. If you need the first row of column names as part of the export, you can change up the export options ever so slightly and have those column names in the first row of the CSV file.
The additional steps are covered below:
- In the Export method: area, select the Custom – display all possible options radio circle instead of Quick – display only the minimal options.
- At the Format-specific options: section, check the Put column names in the first-row checkbox as shown in the provided screenshot below.
- Once again, to execute the Export, click the Go button.
I mentioned in the post opener, that exporting MySQL table and query results to a CSV file are nothing new – as I am sure you are well aware. However, if you do not have access to phpMyAdmin, you can use
SELECT INTO OUTFILE syntax and write to a CSV file just the same. Unsure how to do that? Not to worry. I have previously blogged on this very topic. See the post, MySQL SELECT INTO Syntax Part 2 – Saving to OUTFILE with examples, for more information.
phpMyAdmin provides many export options. CSV files are just one of them. You can expect to see more blog posts covering some of the other formats in the future. Be sure and subscribe to Digital Owl’s Prose so you don’t miss them!
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.