pointkit geocodes a plain address and hands back a MySQL 8 POINT literal in SRID 4326's lat/long axis order — the reverse of Postgres, WKT, and GeoJSON, and the single most common way spatial inserts go quietly wrong.
Almost everything in the spatial world — WKT, GeoJSON, PostGIS — orders coordinates as (longitude, latitude). Since 8.0, MySQL's SRID 4326 follows the strict EPSG definition instead and orders them as (latitude, longitude). If you're coming from Postgres, or copying a longitude/latitude pair straight from a mapping API, it's exactly backwards from what you'd expect.
Get it wrong anywhere longitude is within ±90° — Europe, Africa, most of Asia, South America, eastern North America — and MySQL accepts the geometry without complaint: the point just lands in the wrong place, with nothing in the logs to explain why. Elsewhere you get an out-of-range latitude error instead. pointkit geocodes the address and outputs the literal in MySQL's expected order automatically, so this one never bites.
1600 Amphitheatre Parkway, Mountain View, CA is at latitude 37.4224, longitude -122.0842. MySQL 8.0+ wants latitude first for SRID 4326.
Declaring SRID 4326 on the column makes MySQL reject points in any other reference system, including the SRID 0 points the bare POINT(x, y) constructor makes.
CREATE TABLE places ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), geom POINT NOT NULL SRID 4326 );
INSERT INTO places (name, geom)
VALUES ('Googleplex', ST_GeomFromText('POINT(37.4224 -122.0842)', 4326));
ST_Latitude and ST_Longitude read the coordinates by name, so they're right whichever way round the WKT was written.
SELECT name, ST_Latitude(geom) AS lat, ST_Longitude(geom) AS lng FROM places;
A swapped US address like this one fails loudly, because -122 isn't a valid latitude. Wherever longitude is within ±90° (Europe, Africa, most of Asia, South America and eastern North America) both orders are valid and the swapped point goes in silently. ST_SwapXY swaps it back; run it only on rows you know are wrong.
UPDATE places SET geom = ST_SwapXY(geom) WHERE id = 42; -- a row you've checked is swapped
On MariaDB or MySQL 5.7, write the same point longitude first, POINT(-122.0842 37.4224), and read it back with ST_X (longitude) and ST_Y (latitude).
| Target | Order | Example (37.4224, -122.0842) |
|---|---|---|
| MySQL 8.0+, SRID 4326 | lat, lng | ST_GeomFromText('POINT(37.4224 -122.0842)', 4326) |
| MariaDB, MySQL 5.7 | lng, lat | ST_GeomFromText('POINT(-122.0842 37.4224)', 4326) |
| Postgres / PostGIS | lng, lat | ST_GeomFromText('POINT(-122.0842 37.4224)', 4326) |
| WKT | lng, lat | POINT(-122.0842 37.4224) |
| GeoJSON | lng, lat | {"type":"Point","coordinates":[-122.0842,37.4224]} |
| Leaflet, Google Maps | lat, lng | L.marker([37.4224, -122.0842]) |
ST_GeomFromText or POINT() in MySQL?ST_GeomFromText('POINT(lat lng)', 4326) for geographic coordinates. The shorthand POINT(x, y) constructor makes a point with SRID 0, which a column declared SRID 4326 rejects, and treats x as longitude. pointkit outputs the whole ST_GeomFromText(..., 4326) expression, ready to paste into an INSERT.LOAD DATA INFILE or an ORM import.