Can any one explain how to import a Microsoft Excel file in to a MySQL database? For example, my Excel table looks like this:
Country | Amount | Qty ---------------------------------- America | 93 | 0.60 Greece | 9377 | 0.80 Australia | 9375 | 0.80
828 12 12 silver badges 30 30 bronze badges
asked Aug 21, 2009 at 5:07
13.2k 46 46 gold badges 118 118 silver badges 159 159 bronze badges
[You might take a look at this thread][1] on the MySQL forums. It explains how to do exactly what you want. [1]:forums.mysql.com/read.php?32,216343,216344#msg-216344
Commented Aug 21, 2009 at 5:11 This free utility makes importing excel spreadsheets into mysql tables quick and easy panofish.net/… Commented Jun 13, 2013 at 20:06+1 for a new and different idea. The processing is insanely slow, it first reads each row in file and then upload anything. It took about 15 mins to import 5.2K rows
Commented Sep 20, 2013 at 11:27For some spreadsheets it can be slow, due to number of columns and rows. But, I blame microsofts com-object library which is what is used to read the spreadsheet. My program reads the spreadsheet as fast as the library will allow. The mysql inserts are very fast. If you can eliminate unnecessary columns before importing. that can help.
Commented Jan 27, 2014 at 21:10I had 14 columns on 5173 rows. I had already selected all the empty columns/rows and deleted them to avoid unnecessary processing. Sytem that I was using had 2.5G RAM and core2duo processor, didn't have many processes running, performance tab showed 65% usage in all and a lot of RAM still unused. So, I guess I wouldn't blame the hardware but like you said, MS com objects suck.. I don't know when MS will stop building crap that look like life savers for novices. I'm sick of doing extra crap for MS products.
Commented Jan 28, 2014 at 5:02There's a simple online tool that can do this called sqlizer.io.
You upload an XLSX file to it, enter a sheet name and cell range, and it will generate a CREATE TABLE statement and a bunch of INSERT statements to import all your data into a MySQL database.
(Disclaimer: I help run SQLizer)
answered Sep 22, 2014 at 16:40 15.7k 9 9 gold badges 44 44 silver badges 52 52 bronze badgesGood to know this tool exists, but definitely think about if you should use it or not. If your spreadsheet contains sensitive data (e.g. user emails, passwords, cc info, medical info, etc) it may not be a good idea. This site may not store your data and it may be secure, but there's no way for you to know that for sure.
Commented Aug 2, 2016 at 15:46@DivyeshJesadiya It's free for anything up to 5000 rows. After that you have to pay $10 for a month of usage.
Commented Dec 20, 2016 at 16:24 @doxsi it seems fine to me, what sort of problem did you have with it? Commented Mar 21, 2017 at 10:41@ChrisSchmitz we are super-cautious with security and wrote a blog post recently about how we operate SQLizer blog.sqlizer.io/posts/privacy-at-sqlizer
Commented Mar 28, 2017 at 15:52 It works, pay attention at the Excel format, xlt isn't accepted meanwhile xls is accepted. Commented Apr 5, 2018 at 10:19Below is another method to import spreadsheet data into a MySQL database that doesn't rely on any extra software. Let's assume you want to import your Excel table into the sales table of a MySQL database named mydatabase .
CREATE TABLE sales ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, Country VARCHAR(255), Amount INT, Qty FLOAT ); INSERT INTO sales (Country,Amount,Qty) VALUES ('America',93,0.60), ('Greece',9377,0.80), ('Australia',9375,0.80);
This was the easiest way. Thanks! Just remember to remove the extra Primary Key 'ID' in the SQL, and place an AUTO increment of your choice.
Commented Jul 26, 2019 at 1:09 That's awesome, by far the easiest solution. Great find! Commented Feb 25, 2021 at 10:05When exporting to CSV, [at least] excel 2013 actively attempts to poison data by using VBA-escaped doublequotes, using locale-dependent (based on OS regional settings) decimal separator for 0 values (e.g. ',', while using 'as defined in cell properties' separator for all other values. Best to stay away from CSV.
Commented Apr 12, 2014 at 15:14 Note that this procedure requires that you first create the table, with the appropriate fields. Commented Mar 24, 2016 at 15:00That's isn't the only problem. I am not sure if this procedure deals correctly with carriage return inside a cell in excel. Even the imports from csv to excel fails in that
Commented Apr 12, 2016 at 10:35@afk5min what do you mean by "poison data". All those tags and markup are very useful for the users that are going to obviously import that into another MS product.
Commented Oct 24, 2017 at 14:06 *You meant "The hardest way" not the easiest Commented Jul 8, 2019 at 16:19There are actually several ways to import an excel file in to a MySQL database with varying degrees of complexity and success.