How to Import Excel into MySQL Database?

Migration from Excel into MySQL – The ease of access, power formulas, and the ability to make visually stunning reports has made Microsoft Excel a widely used tool.

Table of Contents

  1. However, managing thousands of sheets can be a time-consuming and resource-intensive task that may also lead to some errors.
  2. A good solution is to import your Excel files to a scalable, reliable, and fast relational database management system like MySQL.
  3. You can import Excel into MySQL either by using simple SQL commands like LOAD DATA or opt for third-party tools.
  4. By importing your files from Excel to MySQL, you can leverage the powerful MySQL engine to quickly query data and perform complex data manipulations.
  5. In this article, you will learn how to effectively import Excel to MySQL using 4 different methods.

What is Excel?

Excel is a powerful spreadsheet program developed by Microsoft. It is a part of the Microsoft Office suite of productivity software. Excel allows users to create, manipulate, and analyze data in tabular form. It provides a wide range of functions and tools for tasks such as calculations, data visualization, charting, and data analysis.

What is MySQL?

MySQL is an open-source relational database management system (RDBMS) that is widely used for managing and storing data. It is one of the most popular databases in the world, known for its reliability, scalability, and ease of use. MySQL is commonly used in web applications to store and retrieve data efficiently.

Why Should You Import Excel into MySQL?

Solve your Data Replication Problems Now

Hevo Data is a No-code Data Pipeline solution that can help you move data from 150+ data sources (including 50+ free sources like Google Drive & Google Sheets) to your desired destination such as MySQL, Data Warehouses, or BI tools in a completely hassle-free & automated manner. Using Hevo you can easily upload your Excel files present on your Google Drive to your MySQL Database.

Hevo also supports MySQL as a source for loading data to a destination of your choice. Using Hevo, you no longer have to worry about how to import Excel file into MySQL workbench.

How to Import Excel File in MySQL: 6 Easy Methods

Method 1: Using Sqlizer.io to Import Excel into MySQL

To connect and convert Excel to MySQL, you can use Sqlizer.io to convert your useful MS Excel files into SQL commands. You can achieve this by following the simple instructions given below:

After the queries have been executed, you can view your data in MySQL using the SELECT command.

Method 2: Using the Load Data Statement to Import Excel into MySQL

Using the LOAD DATA Statement, you can also connect Excel to MySQL. To do that, follow the simple steps given below:

# MySQL Version 8.0.27 LOAD DATA INFILE 'C:/ProgramFiles/MySQLExcel/import excel into mysql.csv' INTO TABLE new_file FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY 'n' IGNORE 1 ROWS; 

In the above process to import an Excel file in MySQL workbench, the .csv file data will be added to the new_file table in your MySQL database without the first row as it contains the row headers.

For this example, the .csv file uses a comma as the delimiter to separate 2 fields. You can also use FIELDS TERMINATED BY ‘t’ or FIELDS TERMINATED BY ‘ ‘ if your file’s fields are separated using a tab or a single space respectively.

Alternatively, you can use the LOAD DATA command directly from the Command Line (CMD).

mysql> load data infile -> 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/import into mysql.csv' -> into table tb_students_cmd -> fields terminated by ',' -> enclosed by '"' -> lines terminated by '\n' -> ignore 1 rows; Query OK, 10 rows affected (0.27 sec) Records: 10 Deleted: 0 Skipped: Warnings: 0 mysql>

Method 3: Import Excel into MySQL using phpMyAdmin

You can also import Excel into MySQL using phpMyAdmin by first converting your .xlsx files to .csv files. For that, you have to first download and phpMyAdmin tool on your system. For this example, a new table named “tb_students_phpmyadmin” has been created in the MySQL Database. To import Excel into MySQL, you can follow the simple steps given below:

After clicking on the Go button, you will observe the data import confirmation messages for all your rows.