Techn4b’s Blog

May 22, 2009

how to upload CSV File to MySQL Database

Filed under: SQL — Tags: , , , , — techn4b @ 09:35
LOAD DATA LOCAL INFILE 'c:\\usr1.csv'
INTO TABLE addressen
FIELDS TERMINATED BY ','
ENCLOSED By '"'
LINES TERMINATED BY '\r\n'

* Load Data Local Infile @ mysql.org
* File saved in UTF8 (OpenOffice 3.0)
* Mysql Query in UTF8 (advanced parameter: default-character-set=UTF8)

mysql_advanced

* Mysql 5.0 show variables:

mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     |
| character_set_connection | latin1                     |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | latin1                     |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

Comment:

23000 rows inserted in 3 seconds

Advertisements

Create a free website or blog at WordPress.com.