-
Notifications
You must be signed in to change notification settings - Fork 5
Import world map into MySQL
Hajime Miyauchi edited this page Dec 30, 2019
·
2 revisions
The result looks like this.
- OS: CentOS Linux release 7.6.1810
- MySQL: 8.0.16
Install the tool ( shp2mysql ).
$ wget https://github.com/hajime-miyauchi/shp2mysql/releases/download/v0.2/shp2mysql-0.2.tar.gz
$ tar xvfz shp2mysql-0.2.tar.gz
$ cd shp2mysql
$ ./configure
$ make
$ sudo make install
Prepare the data. Data is downloaded from Natural Earth . There are several types, but this time I will use 1: 110m Cultural Vectors .
$ wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
$ unzip ne_110m_admin_0_countries.zip
Create the database to be imported.
$ mysql -u root -p
mysql> CREATE DATABASE geotest;
Convert the data and perform the import.
$ shp2mysql ne_110m_admin_0_countries.shp > ne_110m_admin_0_countries.sql
$ mysql -u root -p geotest < ne_110m_admin_0_countries.sql
The result can be confirmed with the following SQL.
SELECT * FROM geotest.ne_110m_admin_0_countries;