位置情報と連動したアプリケーション開発に 役立つMySQL 8.0のGIS機能 MySQL & PostgreSQL Casual Talks in Fukuoka vol.1 2019/09/10 Yoshiaki Yamasaki / 山﨑 由章 MySQL Principal Solution Engineer, Asia Pacific and Japan
デモ手順 5. Googleで「福岡県福岡市博多区博多駅前1丁目」を検索して、 形状を確認 6. MySQL Workbenchから以下のSQLを実行し、Form Editiorでポリゴン データの形状を確認 SELECT * FROM geotest.h27ka40_utf8 WHERE city_name LIKE '博多区' AND s_name = '博多駅前1丁目‘ ; 55
注意事項1 • ogr2ogrでShift_JISのシェープファイルをインポートした時に、文字化けにより エラーが発生する場合があります – 発生したエラー • ERROR 1: MySQL error message:Data too long for column 'XXXXX' at row 1 Description: INSERT INTO<後略> ⇒事前にシェープファイルの文字コードをShift_JISからUTF-8に変換することで回避可能 ※関連するissue - ogr2ogr with MySQL 8 (Shape file import error) #1089 https://github.com/OSGeo/gdal/issues/1089 - Feature request: Support character encodings with MySQL driver #1633 https://github.com/OSGeo/gdal/issues/1633 58 (シェープファイルのフィールド名に日本語を使用している場合、UTF-8に変換することで桁あふれする可能性が あることに注意)
注意事項2 • MySQL 8.0でデフォルトの認証方式を使用している場合、ogr2ogrで 接続できません – MySQL 8.0の設定で「default-authentication-plugin=mysql_native_password」 としてからMySQLユーザーを作成することで回避可能 – ogr2ogrがMySQL 8.0のデフォルト認証方式に対応したドライバを使用していないことが 原因です。本問題に関するissueを登録済みです。 • ogr2ogr with MySQL 8 (MySQL connect failed with caching_sha2_password plugin) #910 https://github.com/OSGeo/gdal/issues/910 • libmysql-client version is old for MySQL 8.0 #132 https://github.com/gisinternals/buildsystem/issues/132 59
デモ手順 3.MySQL Shellを使ってJSONファイルをインポートする > mysqlsh -u root -p --import h27ka23.geojson --schema=geotest Creating a session to 'root@localhost/geotest' Please provide the password for 'root@localhost': **** Save password for 'root@localhost'? [Y]es/[N]o/Ne[v]er (default No): Fetching schema names for autocompletion... Press ^C to stop. Your MySQL connection id is 23 (X protocol) Server version: 8.0.16-commercial MySQL Enterprise Server - Commercial Default schema `geotest` accessible through db. Importing from file "h27ka23.geojson" to collection `geotest`.`h27ka23` in MySQL Server at localhost:33060 Processed 48.38 MB in 1 document in 5.2862 sec (0.19 document/s) Total successfully imported documents 0 (0.00 documents/s) Result of json_binary::serialize() was larger than max_allowed_packet (4194304) - truncated [実行例] 67