The following methods connect to MySQL through OGR’s MySQL driver, thus avoiding the need to set up an ODBC connection.
Connecting to Spatial Data in MySQL
This section describes how to display a spatial MySQL table (meaning that the table has a column of type geometry) in MapServer. OGR’s MySQL driver was expanded in OGR version 1.3.2 to support access to MySQL spatial tables.
- MapServer compiled with OGR support
- OGR/GDAL version 1.3.2 or more recent compiled with MySQL support
Create MapServer Layer
DATA “SELECT SHAPE,admin_name from province”
NAME “Spain Provinces”
COLOR 240 240 240
OUTLINECOLOR 199 199 199
COLOR 0 0 0
OUTLINECOLOR 255 255 255
END # layer
The DATA parameter is used to perform the SQL select statement to access your table in MySQL. The geometry column is required in the select statement; in the above example the SHAPE column is the geometry column in the province table.
Connecting to non-Spatial Data in MySQL
This section describes how to display a non-spatial MySQL table (meaning the table does not have a column of type geometry) in MapServer.
Support for this functionality is found in GDAL/OGR 1.2.6 and older on Windows and GDAL/OGR 1.3.2 on Linux.
MySQL database containing a table with fields containing x and y coordinates
.ovf file, a small xml file you will create
MapServer compiled with OGR version supporting this functinality
OGR (MapServer OGR document)
Vector Data (MapServer Vector Data Access Guide)
MySQL wiki page (describes the deprecated mygis support)