Created
August 11, 2015 23:18
-
-
Save tylerpearson/73c5c9c9540c06a89e78 to your computer and use it in GitHub Desktop.
SQL import MaxMind GeoIP CSV into MySQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| USE users_info; | |
| CREATE TABLE IF NOT EXISTS `geoips` ( | |
| `id` INT(1) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT, | |
| `ipstart` VARCHAR(50) COLLATE UTF8_GENERAL_CI NOT NULL, | |
| `ipend` VARCHAR(50) COLLATE UTF8_GENERAL_CI NOT NULL, | |
| `locid_start` INT(1) UNSIGNED ZEROFILL NOT NULL, | |
| `locid_end` INT(1) UNSIGNED ZEROFILL NOT NULL, | |
| `country_code` VARCHAR(4) COLLATE UTF8_GENERAL_CI NOT NULL, | |
| `country` VARCHAR(100) COLLATE UTF8_GENERAL_CI NOT NULL, | |
| PRIMARY KEY( `id`,`ipstart`,`ipend`, `locid_end`, `country` ) | |
| ) DEFAULT CHARSET=UTF8 COLLATE=UTF8_GENERAL_CI AUTO_INCREMENT=1 ; | |
| LOAD DATA INFILE '/Users/tylerpearson/Dropbox/scripts/user-import/GeoIPCountryWhois.csv' INTO TABLE `geoips` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n'( | |
| `ipstart` , `ipend` , `locid_start` , `locid_end` , `country_code` , `country` | |
| ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment