Skip to content

Convert Excel to MySQL

Drop your Excel file to get a MySQL script with CREATE TABLE and INSERT statements. Each column gets a type, and every fix is listed with its row and column.

Your file
xlsxclientes_2024.xlsxSample file, 7 kB
Your database

4 rows converted, 10 fixes, none rejected

Show
The first rows of clientes_2024.xlsx, with each fix marked
Row
500127Peña Muñoz0123403/02/2024sí1.234,50
600128José Ángel0987015/02/2024noN/A
700129Zoë Ortíz4410029/02/2024sí-12,00
800130Ñuño Castañeda0670011/03/2024no980,75
-- Written by IntoSQL for MySQL.

SET NAMES utf8mb4;
SET SESSION sql_mode = REPLACE(@@sql_mode, 'NO_BACKSLASH_ESCAPES', '');
START TRANSACTION;

CREATE TABLE clientes_2024 (
    no_cliente varchar(8) NOT NULL COMMENT 'Nº Cliente',
    nombre varchar(16) NOT NULL,
    c_p varchar(8) NOT NULL COMMENT 'C.P.',
    alta date NOT NULL,
    activo tinyint(1) NOT NULL,
    saldo decimal(6,2)
) DEFAULT CHARSET=utf8mb4;

INSERT INTO clientes_2024 (no_cliente, nombre, c_p, alta, activo, saldo) VALUES
('00127', 'Peña Muñoz', '01234', '2024-02-03', TRUE, 1234.50),
('00128', 'José Ángel', '09870', '2024-02-15', FALSE, NULL),
('00129', 'Zoë Ortíz', '44100', '2024-02-29', TRUE, -12.00),
('00130', 'Ñuño Castañeda', '06700', '2024-03-11', FALSE, 980.75);

COMMIT;

Fixes

  1. The header is on row 4; the rows above it were left out.
  2. Row 9 ("TOTAL") is a total, so it was left out.
  3. Column "Nº Cliente" is named no_cliente so MySQL reads it without quotes.
  4. Column "C.P." is named c_p so MySQL reads it without quotes.
  5. Leading zeros kept in "Nº Cliente": 00127 stays 00127, stored as text.
  6. Leading zeros kept in "C.P.": 01234 stays 01234, stored as text.
  7. 15/02/2024 proves the dates in "Alta" are day-first, so 03/02/2024 is read as 2024‑02‑03.
  8. "Activo" holds yes and no words (sí, no), stored as boolean.
  9. Numbers in "Saldo" use a decimal comma: 1.234,50 is read as 1234.50.
  10. N/A in "Saldo" read as empty (1 of 4 values).

Your file is converted on this computer and never uploaded.

Other samples:

From Excel to MySQL, column by column

The sample above, clientes_2024.xlsx, as IntoSQL writes it for MySQL: what each column holds in the file, the type it gets and how its first value lands in the script.

In the fileFirst valueColumnMySQL typeIn the script
Nº Cliente00127no_clientevarchar(8)'00127'
NombrePeña Muñoznombrevarchar(16)'Peña Muñoz'
C.P.01234c_pvarchar(8)'01234'
Alta03/02/2024altadate'2024-02-03'
Activosíactivotinyint(1)TRUE
Saldo1.234,50saldodecimal(6,2)1234.50

Load the script into MySQL

The download is a plain .sql file. Run it with MySQL's own tools.

From a terminal

mysql --default-character-set=utf8mb4 mydb < clientes_2024.mysql.sql

The script sets utf8mb4 itself; the flag makes the client send it the same way, so accents arrive intact.

From a database tool

In MySQL Workbench, choose File, Run SQL Script, and pick the file.

Without a scriptPro

IntoSQL Pro loads the file straight into MySQL from the desktop app or the command line, without writing a script.

intosql load clientes_2024.xlsx --into mysql://user@localhost/mydb

What to know about Excel files and MySQL

What IntoSQL reads in Excel files

  • The header row is found even when titles or notes sit above it, and a totals row at the end is left out.
  • Dates stored as Excel serial numbers become real dates, in both the 1900 and the 1904 date systems.
  • Codes with leading zeros, like 00127, stay text. When a workbook has several sheets, you pick the sheet.

What to know about MySQL

  • Yes and no values become tinyint(1). Text up to 255 characters is varchar; longer text is text, mediumtext or longtext by size.
  • The script uses utf8mb4 and sets the SQL mode, so accents, emoji, backslashes and line breaks load as written.
  • MySQL's datetime stores no time zone.

How each kind of value is stored in MySQL

ValueMySQL
Yes and notinyint(1)
Whole numbersint
Large whole numbersbigint
Decimalsdecimal(p,s)double
Floating-point numbersdouble
Datesdate
Times of daytime(6)time
Dates with a timedatetime(6)datetime
Dates with a time and offsetdatetime(6)datetime
Textvarchar(n)textmediumtextlongtext

Questions about Excel to MySQL

Not answered here? Write to us from the contact page and a person replies. Contact page

How do I convert Excel to MySQL?

Drop your file on the converter at the top of this page. It finds the header, reads every value and writes the MySQL script, listing each fix it made. Download the script and run it with the mysql client.

Which sheet of the workbook is converted?

The first visible sheet. When a workbook has more than one, a Sheet option appears, so you can pick another.

Which MySQL types does it use?

Yes and no values become tinyint(1), whole numbers int, decimals decimal(p,s), dates date, dates with a time datetime(6) and text varchar(n). Sizes come from the longest value in each column.

Does it keep leading zeros in MySQL?

Yes. A code such as 00127 stays text, so MySQL stores it as varchar(8) and the script writes it as '00127'.

Can it load the data into MySQL without a script?

Yes, with IntoSQL Pro. The desktop app and the command line connect to MySQL and load the rows straight in, creating the table first.

How big can the Excel file be?

In the browser, a workbook is read whole, so the limit is the memory the browser gives this page. The desktop app and the command line take workbooks of any size; on an Apple M4 laptop the command line converts a 117 MB workbook of a million rows in about a second.