【转】Instruction about how to load “.csv” file into MySQL

1.       Change the configuration file of MySQL. (MySQL can’t identify some incorrect strings of the .csv file we want to load, so that we have to change the setting of MySQL)


l         Open your "my.ini" file within the MySQL installation directory, and look for the text "sql-mode". Find:


l         Add the following code to “my.ini” file



2.       Download the .csv files and unzip it:


File NameDownload Link
1. GeoIPCountryCSV.zip (It contains one database file)http://www.maxmind.com/app/geoip_country
2. GeoLiteCity_20100601.zip (It contains two database files)http://www.maxmind.com/app/geolitecity



Note: Actually, there is one database named GeoLiteRegion, which doesn’t have free version right now. So we didn’t choose to use it.




3.       Use MySQL Workbench to load the unzipped .csv files to database


l         According to the number of columns of the .csv file, we need to create the corresponding table and give a name to each column.

l         After the table has been established, we can use the following command to automatically load the data :


If you guys are still confusing about the code above, you check the following websites out:

http://forums.mysql.com/read.php?79,219901,219901
http://www.tech-recipes.com/rx/2345/import_csv_file_directly_into_mysql/

建议使用dat文件读取。


Total views.

© 2013 - 2018. All rights reserved.

Powered by Hydejack v6.6.1