関連するissue • ogr2ogr with MySQL 8 #782 https://github.com/OSGeo/gdal/issues/782 • Issue with Mysql import #899 https://github.com/OSGeo/gdal/issues/899 • ogr2ogr with MySQL 8 (Wrong SRID) #905 https://github.com/OSGeo/gdal/issues/905 • ogr2ogr with MySQL 8 (Wrong Axis Order) #906 https://github.com/OSGeo/gdal/issues/906 ⇒これらのissueはGDAL 2.3.2で修正済み 10
注意事項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 54
注意事項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 55
デモ手順 3.MySQL Shellを使ってJSONファイルをインポートする > mysqlsh -u root -p --import h27ka15.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 18 (X protocol) Server version: 8.0.16-commercial MySQL Enterprise Server - Commercial Default schema `geotest` accessible through db. Importing from file "h27ka15.geojson" to collection `geotest`.`h27ka15` in MySQL Server at localhost:33060 .. 1 Processed 50.00 MB in 1 document in 11.9812 sec (0.08 document/s) Total successfully imported documents 1 (0.08 document/s) [実行例] 64