I want to store WGS84 coordinates in a MySQL 5.7 database. After much reading, I think I should use the POINT datatype with a SPATIAL INDEX. But I am very confused about SRSs, SRIDs, lat/long vs long/lat, etc.

Could someone give me a very simple example of how I would create a table with location_name and coordinates columns that would correctly store a string location name, and lat/long values in decimal degrees?

And then, an example of how I would insert data into this table correctly?

I am reading conflicting information on what SRID I should use (0? 4326?) in order to do distance calculations correctly. Also reading conflicting information on whether it should be POINT(lat, long) or POINT(long, lat).


The axis order of a coordinate reference system is determined by it's definition by its named authority.

Most widely used authority for projections is EPSG

EPSG::4326 is a coordinate reference system defined by the EPSG authority.

Looking at the EPSG Geodetic Parameter Registry for EPSG::4326 we can see (WKT version) that the correct axis order is lat/long:

  DATUM["World Geodetic System 1984",
    ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1.0]]],

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.