Networking, Programming and Graphics - Tutorials
ONLINEHOWTO.net Tutorials Category

How to Import CSV file into MySql database

Type: Picture Networking, Programming and Graphics - Tutorials
Networking, Programming and Graphics - Tutorials
Level: Intermediate Networking, Programming and Graphics - Tutorials Networking, Programming and Graphics - Tutorials 
Networking, Programming and Graphics - Tutorials
Date: 2010-Feb-08
Networking, Programming and Graphics - Tutorials
Visited: 1677 times
Networking, Programming and Graphics - Tutorials
Rating: Networking, Programming and Graphics - Tutorials
Networking, Programming and Graphics - Tutorials
Published: Ivory Morhuld

We will continue from our previous tutorial for How to Import Excel XLS file into MySql database into the exact solution of the problem - Converting the file into CSV (Comma Separated Value) and next easily importing into MySql.
"1";"PalmOS"
"2";"Windows XP"
"3";"Windows Vista"
"4";"Windows Mobile"
"5";"Windows CE.NET"
"6";"Blackberry"
"9";"Windows 2000"
"7";"Windows 98"
"8";"Windows 95"
"10";"Windows 2003"
"11";"Windows XP64"
"12";"PocketPC 2000"
"13";"PocketPC 2002"
"19";"Windows 7"
This method is very good for importing large file with many rows because, filling the table is made locally on the computer where is both MySql server and CSV file. This will resulted over the speed and execution time which is problem if you make it with PHP script (PhpMyAdmin for example) like I will show you at the and of this tutorial.

When we already have our CSV file prepared we can use MySql console to enter a command for filling selected table with the data from CSV file. This can be done like shown in the code bellow:

Please note that you have to specify correct path to CSV file and of course this file can be accessible for this user. Also when login in console you have to use this user which have correct credentials for writing data in this MySql database and table.
C:\mysql\bin>mysql.exe -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 603
Server version: 5.1.35-community-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> LOAD DATA INFILE 'path/file.csv' INTO TABLE my_table
OK, well done. But now we will examine the more easiest way - to import the Excel CSV file into MySql database visually - just with some mouse clicks using PhpMyAdmin.

First login to PhpMyAdmin, select database and desired table and click on import tab like shown in the picture below:
How to Import CSV file into MySql database
Next select Excel CSV file, click on the checkboxes which define the CSV format and click Go button. When importing is finished we will have ready for use table with filled data.
How to Import CSV file into MySql database
Rate this tutorial:                    
Post Comment

    • ( atentojfa [ at ] gmail . com ),

      posted on 2010-Mar-31 | 04:19:14 AM
      Thanks godd! finally ! I´ll try it.
Need a specific tutorial? Do not hesitate and submit a request!
Your e-mail: