sumber : http://www.w3resource.com/mysql/exporting-and-importing-data-between-mysql-and-microsoft-excel.php
Description
In this page we will discuss how to import data from Microsoft Excel to MySQL and how to export data from MySQL to Microsoft Excel.
We will cover the topic in three parts -
1. Installing and configuring MySQL ODBC driver.
2. Import data from MySQL into Excel.
3. Export data from Excel into MySQL.
Installing and configuring MySQL ODBC driver
Download MySQL ODBC driver from MySQL dev.mysql.com/downloads/connector/odbc/5.1.html.MySQL ODBC driver is required for connecting to MySQL from Microsoft Excel.
Install MySQL ODBC driver by executing the msi file you have downloaded.
To configure the MySQL ODBC driver (we have used Windows 7, 32bit), open Data Sources(ODBC) by clicking Start > Control Panel > System and Security > Administrative Tools > Data Sources(ODBC).
Click on Add button, scroll down to select MySQL ODBC 5.1 driver from the list and click finish.
This will ask to provide information necessary to connect to the MySQL server. You have to select the database by clicking the arrow next to the database text box.
Now click on the Test button and if everything goes well, we will see a message like bellow.
Continue to click on OK buttons (thrice) now to complete the configuration.
how to Import data from MySQL into Excel
In Excel (we have used Microsoft Office 2003), open Select Data Source by clicking Data > Import External Data > Import Data.MySQL ODBC driver is required for connecting to MySQL from Microsoft Excel.
Install MySQL ODBC driver by executing the msi file you have downloaded.
To configure the MySQL ODBC driver (we have used Windows 7, 32bit), open Data Sources(ODBC) by clicking Start > Control Panel > System and Security > Administrative Tools > Data Sources(ODBC).
Click on New Source button, select Other/advanced and click Next.
In the next window, select connection tab and provide all the necessary information as shown bellow.
Click on the Test Connection tab and if everything goes well, you will see a message like bellow.
Now click on the Test button and if everything goes well, we will see a message like bellow.
Select the MySQL table from where you want to import data and click Next.
Add the description and click Finish.
Select the data source in the next window and click Open.
The very next window will ask you whether you want to save the data in the existing worksheet or some where else. We opted for existing worksheet.
Click OK now. Data from book_mast table of bookinfo database is imported to the Excel now.
how to Export data from Excel into MySQL
Now, we will discuss how to Export data from Excel into MySQL.And Import data from MySQL into Excel in the second part.
Export data from Excel into MySQL
We will create a copy of author table of bookinfo database and name it author_2. For that we will execute the following command -
CREATE TABLE author_2 LIKE author;
Result of the command will be like following - Export the data from customer table to Excel and save it as author.csv.
Import the author.csv file into the author_2 table using LOAD DATA INFILE statement.
load data infile 'D:\\author.csv' into table author_2 fields terminated by ',' lines terminated by '\n';
This is what happens when you run the above command in the MySQL prompt.

