pengrad / mysql-geoip

Load MaxMind GeoIP databases to MySQL
0 stars 0 forks source link

Table 'geoip.country' doesn't exist #1

Open rasa opened 7 years ago

rasa commented 7 years ago
root@localhost:~/mysql-geoip# python run.py                 
Download http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip in geo_zip/GeoIPCountryCSV.zip
Download http://geolite.maxmind.com/download/geoip/database/GeoIPv6.csv.gz in geo_zip/GeoIPv6.csv.gz
Download http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.zip in geo_zip/GeoLiteCity-latest.zip
Download http://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.csv.gz in geo_zip/GeoLiteCityv6.csv.gz
Extracting geo_zip/GeoIPv6.csv.gz
Extracting geo_zip/GeoLiteCity-latest.zip
Extracting geo_zip/GeoLiteCityv6.csv.gz
Extracting geo_zip/GeoIPCountryCSV.zip
Convert to IPv6 geo/GeoIPCountryWhois.csv to geo/GeoIPCountryWhois.csv.v6.csv
Convert to IPv6 geo/GeoLiteCity_20170307/GeoLiteCity-Blocks.csv to geo/GeoLiteCity_20170307/GeoLiteCity-Blocks.csv.v6.csv
Create database
sh: 1: /usr/local/bin/mysql: not found
Load file geo/GeoIPCountryWhois.csv.v6.csv into table csv_country4
433296 rows
Load file geo/GeoIPv6.csv into table csv_country6
31844 rows
Load file geo/GeoLiteCity_20170307/GeoLiteCity-Blocks.csv.v6.csv into table csv_city4
6202167 rows
Create index on csv_city4(locid)
Insert into ip_new from csv_country4
Traceback (most recent call last):
  File "run.py", line 161, in <module>
    build_db()
  File "run.py", line 107, in build_db
    """)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 226, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorvalue
_mysql_exceptions.ProgrammingError: (1146, "Table 'geoip.country' doesn't exist")
pengrad commented 7 years ago

So, try to fix mysql_cmd in config.py

rasa commented 7 years ago

Thanks for the response. I fixed mysql_cmd in config.py, but I still get the same error. In the geoip database, I don't see a country table, only:

mysql> show tables;
+-----------------+
| Tables_in_geoip |
+-----------------+
| csv_city4       |
| csv_country4    |
| csv_country6    |
| ip_city_new     |
| ip_new          |
+-----------------+
5 rows in set (0.00 sec)
pengrad commented 7 years ago

Oh, country table should be prepared before running script. Maybe i can find it for you. But next is city_ext table. It's maybe useless for you as i used it only for cities from 3 specific country

rasa commented 7 years ago

If you can supply the table formats (SHOW CREATE TABLE country;) I will prepare a PR to add it to create_db.sql

pengrad commented 7 years ago

I added country.sql I think city_ext can be removed

rasa commented 7 years ago

Thanks for adding the country table. The city_ext table is referenced at https://github.com/pengrad/mysql-geoip/blob/master/run.py#L120 and again at https://github.com/pengrad/mysql-geoip/blob/master/run.py#L140