7

I have used Grass GIS imported a .shp file; I now want to export this file to MySQL.

I understood that MySQL will contain the function of all three the files necessary in a Shape file system (.shp - .db - .shx). The import works fine but when I try to export to MySQL I get the following error.

ERROR: Unable to open OGR data source 'Test'

At some stage there was also a message that indicated that MySQL or MySQL Spatial is not available.

I have not used QGIS before. However have purchased GlobalMapper and want to use MySQL instead of Shapefiles. The database is too big to recapture all the info in MySQL I will have to find a way to convert the data from shapefile to MySQL.

  • The data source is not input data, your shapefile ? If yes, check your shp – user3120 Feb 23 '14 at 13:13
6

Your best bet is to use OGR directly from the command line. OGR's MySQL Driver page has an example of how to use ogr2ogr to import a shapefile:

www.gdal.org/drv_mysql.html

2

The best available answer is to use ogr2ogr to import shape files. FWtools is a great tool to import shape files into mysql here is an example

ogr2ogr -f MySQL MySQL:database_name,host=localhost,user=root,password=1234 C:\route_path\line.shp -nln datatable_name -update -overwrite -lco engine=MYISAM

more details at

https://stackoverflow.com/questions/15123765/how-to-import-shape-file-into-mysql

but frankly it suffers errors while importing large shapefiles. So if you are not going to import large files then it is quite great but if you are going to import the shapefiles that contain polygon as geom you are gonna have a bad time as it scarmbles the geom. If you can stick with POSTGIS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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