Want to import data from Excel file to MySQL ?
Try Withdata FileToDB, a desktop Excel to MySQL converter for Windows, MacOS, and Linux, Convert Excel to MySQL, Easy and Fast.
- Can run in GUI mode, Step by Step, just a few mouse clicks.
- Can run in Command line, for Scheduled Tasks and Streams.
- Import Excel to MySQL locally and privately, avoid uploading Excel file(s) to online services.
- Support Windows, Linux, and macOS.
Download Withdata FileToDB
Windows 64 bit
Windows 32 bit
Linux .deb (For Debian, Ubuntu) 64 bit
Linux .rpm (For Red Hat, Fedora, SUSE) 64 bit
MacOS 64 bit
Excel and MySQL disagree about almost everything a cell can hold. The import is four
clicks; the failures all happen in the mapping. These are the four you will meet on the first run:
| What goes wrong | Why | Fix |
|---|---|---|
Truncated value, or Data too long for column |
A VARCHAR(50) guessed from the first rows vs. a cell that got longer further down |
Size the column from the whole sheet, not from the sample; text that can grow belongs in TEXT |
Accented or Chinese text becomes ? or mojibake |
The connection or the table is utf8 (3 bytes) rather than utf8mb4 |
Table and connection charset utf8mb4; the 4-byte characters then survive |
| Dates shift by hours, or land in 2038 | TIMESTAMP is stored in UTC and converted per session (and ends at 2038); DATETIME is stored as written |
Use DATETIME for wall-clock times, TIMESTAMP only when you want conversion |
| The whole batch rolls back on one bad row | InnoDB + strict mode: the first error aborts the statement, and the transaction takes the rest with it | Load in batches, or stage into a text table and cast in INSERT … SELECT |
Import data from Excel to MySQL in 4 steps
Choose Excel file -> Set MySQL table -> Preview MySQL table -> Import Excel to MySQL
Choose MySQL and logon.
Click “Wizard – 1 File To 1 Table” for “Excel to MySQL”.
Select the “Excel” file type.
then show the wizard.
Step #1. Open an Excel file.
Step #2. Select a MySQL table and config fields.
Step #3. Preview MySQL table.
Step #4. Import Excel to MySQL.
More about Excel to MySQL converter
Download Withdata FileToDB
Windows 64 bit
Windows 32 bit
Linux .deb (For Debian, Ubuntu) 64 bit
Linux .rpm (For Red Hat, Fedora, SUSE) 64 bit
MacOS 64 bit
Excel type to MySQL type
The table has to exist with the right types before the rows arrive; the mapping screen then has something
sane to write into. What the cells actually are, and what they should become:
| In the sheet | In MySQL | Watch out for |
|---|---|---|
| Date, datetime | DATE, DATETIME |
DATETIME keeps what the sheet shows; TIMESTAMP converts to UTC and is limited to 2038. |
| Prices, amounts | DECIMAL(12,2) |
FLOAT/DOUBLE will drift; the sheet may already have rounded. |
| Names, addresses | VARCHAR(n) or TEXT |
VARCHAR counts characters (not bytes) in MySQL 8, but the index length limit still bites on long keys. |
| Yes / no column | BOOLEAN (= TINYINT(1)) |
It accepts 1/0; the strings true/false are cast, yes/no are not. |
| Identifiers, barcodes | VARCHAR(32) |
If Excel already dropped the leading zeros, the import cannot put them back. |
Identifiers: backticks and the case question
MySQL quotes identifiers with `backticks`, and whether OrderDate and
orderdate are the same thing depends on how the server was configured
(lower_case_table_names) — and, on Linux, on the filesystem. A header with a space
(Order Date) needs quoting everywhere it is used; a reserved word such as order
or key does too. Renaming the columns during the mapping step is cheaper than quoting them
forever.
Finding the rows that fail
InnoDB is transactional and strict by default: one bad value aborts the statement, and the rollback takes
the whole batch with it. Two side effects surprise people: the AUTO_INCREMENT counter is not
rolled back (so ids have gaps), and INSERT IGNORE or a relaxed sql_mode will
silently truncate instead of failing — the data looks imported and is wrong.
- Batch the load so a failure costs one batch, not the workbook.
- Stage first: a table where every column is
TEXT, thenINSERT … SELECTwith
explicit casts. The cast error names the value; the alternative names a row number. - Keep the sheet row number in the staging table — it is the only way back to the spreadsheet.
Many sheets, many files, every night
One sheet per month is the usual shape: append every sheet to the same table, or create one table per sheet
when the sheets are different entities. A folder of workbooks runs as one job, and the session can be saved and
scheduled, so the nightly import is a replay of the same configuration.
Going the other way — MySQL back to a spreadsheet — is
MySQL to Excel. For the PostgreSQL
version of this guide, with the same mapping logic and different type names, see
import
Excel into PostgreSQL.