4

I am trying to dump shapefile data into MySQL using GDAL ogr2ogr command

ogr2ogr –f MySQL MySQL:SHP_DB,host=localhost,user=root,password=root feature_object.shp  -nln phil_custom -update -overwrite -lco engine=MYISAM

I am getting this error:

    -
FAILURE:
Unable to open datasource `MySQL' with the following drivers.
  -> PCIDSK
  -> netCDF
  -> JP2OpenJPEG
  -> PDF
  -> ESRI Shapefile
  -> MapInfo File
  -> UK .NTF
  -> OGR_SDTS
  -> S57
  -> DGN
  -> OGR_VRT
  -> REC
  -> Memory
  -> BNA
  -> CSV
  -> NAS
  -> GML
  -> GPX
  -> LIBKML
  -> KML
  -> GeoJSON
  -> Interlis 1
  -> Interlis 2
  -> OGR_GMT
  -> GPKG
  -> SQLite
  -> OGR_DODS
  -> ODBC
  -> WAsP
  -> PGeo
  -> MSSQLSpatial
  -> OGR_OGDI
  -> PostgreSQL
  -> MySQL
  -> OpenFileGDB
  -> XPlane
  -> DXF
  -> Geoconcept
  -> GeoRSS
  -> GPSTrackMaker
  -> VFK
  -> PGDUMP
  -> OSM
  -> GPSBabel
  -> SUA
  -> OpenAir
  -> OGR_PDS
  -> WFS
  -> HTF
  -> AeronavFAA
  -> Geomedia
  -> EDIGEO
  -> GFT
  -> SVG
  -> CouchDB
  -> Cloudant
  -> Idrisi
  -> ARCGEN
  -> SEGUKOOA
  -> SEGY
  -> XLS
  -> ODS
  -> XLSX
  -> ElasticSearch
  -> Walk
  -> CartoDB
  -> AmigoCloud
  -> SXF
  -> Selafin
  -> JML
  -> PLSCENES
  -> CSW
  -> VDV
  -> TIGER
  -> AVCBin
  -> AVCE00
  -> HTTP

I could not find any solution to this error. What could be the possible cause of this error as I have dump shapefiles data successfully with the same command?

GDAL version is- GDAL 2.1.0, released 2016/04/25

OS- ubuntu 14.04


4
  • What do you get with ogrinfo MySQL:SHP_DB,host=localhost,user=root,password=root?
    – user30184
    Dec 21, 2016 at 9:01
  • Usage: ogrinfo [--help-general] [-ro] [-q] [-where restricted_where|@filename] [-spat xmin ymin xmax ymax] [-geomfield field] [-fid fid] [-sql statement|@filename] [-dialect sql_dialect] [-al] [-so] [-fields={YES/NO}] [-geom={YES/NO/SUMMARY}] [-formats] [[-oo NAME=VALUE] ...] [-nomd] [-listmdd] [-mdd domain|all]* [-nocount] [-noextent] datasource_name [layer [layer ...]] FAILURE: No datasource specified.
    – AMahajan
    Dec 21, 2016 at 9:14
  • 1
    Try ogrinfo MySQL:"SHP_DB,host=localhost,user=root,password=root"
    – user30184
    Dec 21, 2016 at 9:17
  • It is showing : INFO: Open of MySQL:SHP_DB,host=localhost,user=root,password=root' using driver MySQL' successful. But again after running ogr2ogr , i am getting the same error
    – AMahajan
    Dec 21, 2016 at 9:35

3 Answers 3

2

I changed my syntax from this

ogr2ogr –f MySQL MySQL:SHP_DB,host=localhost,user=root,password=root feature_object.shp  -nln phil_custom -update -overwrite -lco engine=MYISAM

to this

ogr2ogr MySQL:SHP_DB,host=localhost,user=root,password=root feature_object.shp  -nln phil_custom -update -overwrite -lco engine=MYISAM

and it worked !! I don't know the reason.

2
  • For some reason GDAL did not understood the "-f MySQL" part of your command. It you have copy-pasted the command the dash character in front of "f" may be some other character that just looks alike. If that is the case it may work if you write that parameter from the keyboard.
    – user30184
    Dec 21, 2016 at 13:03
  • You are correct but I tried that too, wrote whole command myself.
    – AMahajan
    Dec 22, 2016 at 4:45
1

There looks to be syntax differences between an example from BostonGIS and your query

ogr2ogr –f MySQL MySQL:SHP_DB,host=localhost,user=root,password=root feature_object.shp  -nln phil_custom -update -overwrite -lco engine=MYISAM

Example

ogr2ogr -f "MySQL" MYSQL:"mydb,host=myhost,user=mylogin,password=mypassword,port=3306" -nln "world" -a_srs "EPSG:4326" path/to/world_adm0.shp 

I would attempt running the below:

ogr2ogr –f "MySQL" MYSQL:"SHP_DB,host=localhost,user=root,password=root"  -nln "phil_custom" -update -overwrite -lco engine=MYISAM feature_object.shp
0

sometimes if you have used the ' ' in the filename like 'rainfall UK', this error would be happen. But you try to change it as 'rainfall_UK', it would be fine

Your Answer

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

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