Advertisement
rg443

geoip lite asn mysql import

Jan 7th, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.70 KB | None | 0 0
  1. /*
  2. cd /tmp
  3. curl -O http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum2.zip
  4. unzip GeoIPASNum2.zip
  5. */
  6.  
  7. drop table if exists geoipasn;
  8. CREATE TABLE geoipasn (
  9.     i1 INT(10) UNSIGNED NULL primary key,
  10.    i2 INT(10) UNSIGNED NULL,
  11.    asn INT(10) UNSIGNED default convert (replace(substring_index(asname,' ',1),'AS',''),unsigned),
  12.    asname varchar(100) NULL,
  13.    index asn(asn)
  14. )
  15. ENGINE=MyISAM;
  16.  
  17. truncate table geoipasn;
  18. load data infile '/tmp/GeoIPASNum2.csv' into table geoipasn
  19. FIELDS TERMINATED BY ','
  20. OPTIONALLY ENCLOSED BY '"'
  21. LINES TERMINATED BY '\n'
  22. (i1,i2,asname);
  23.  
  24. optimize table geoipasn;
  25. -- select asn,asname,sum(1)n,sum(i2-i1+1)ips from geoipasn group by asn with rollup;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement