My problem is:

when i open my shapefile in Qgis its fine.

but i need to export my shapefile to a Database MySQL/MariaDB.

i export my file with ogr2ogr with this command:

ogr2ogr -f "MySQL"   MYSQL:"MyDB,host=localhost,user=admin,password=password,port=3306" -a_srs "EPSG:4326" fishingzone.shp

i dont get any errors from ogr2ogr like i had for other files. then i import the data from the database to Qgis and the result is not good.(some polygons are there but most are not)

i tried to divise the file into smaller files but same result as with the big file.

im using Gdal-bin 2.4 Am i missing an argument or should i use an other version of Gdal ? Any hints ?

  • Have you tried validating the geometry of the shapefile before exporting? You can find it in the toolbox. How some tools handle invalid geometry ranges wildly. Another option is to load the data directly from QGIS into the database. I have better luck with that generally.
    – RomaH
    Jul 15, 2021 at 17:37
  • when i open my shapefile in Qgis its fine. thanks i will look into how to export data from Qgis Jul 15, 2021 at 17:53
  • i dont know what Qgis did but it worked Jul 15, 2021 at 18:15
  • I don't know why it seems more reliant but it is, I think it still uses ogr in the backend.
    – RomaH
    Jul 15, 2021 at 19:00
  • it does use ogr in the backend... its doing some sort of black magic Jul 15, 2021 at 20:40

1 Answer 1


I found the solution to my problem for the ogr2ogr command

I needed to add the -lco engine=MYISAM flag

According to mysql doc :

In MySQL 8.0, it is normally necessary to use ENGINE to specify the MyISAM storage engine because InnoDB is the default engine.

It looks like its how MySQL handles the data in the backgroud.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.