How to Fix MySQL Error 4105 (ER_SRS_INVALID_LATITUDE_OF_ORIGIN)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mysql error 4105 when a spatial reference system has an invalid latitude of origin. To fix it, set the latitude of origin between negative 90 and positive 90 degrees. This failure uses the symbol ER_SRS_INVALID_LATITUDE_OF_ORIGIN and returns SQLSTATE SR002. The database blocks the query because the spatial math cannot run outside valid polar bounds. You must check the angular unit in your spatial definition and adjust the number. Root causes of mysql error 4105 in the database engine

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You get mysql error 4105 when a spatial reference system has an invalid latitude of origin. To fix it, set the latitude of origin between negative 90 and positive 90 degrees.

This failure uses the symbol ER_SRS_INVALID_LATITUDE_OF_ORIGIN and returns SQLSTATE SR002. The database blocks the query because the spatial math cannot run outside valid polar bounds. You must check the angular unit in your spatial definition and adjust the number.

Root causes of mysql error 4105 in the database engine

MySQL uses spatial reference systems to map coordinates onto the surface of the earth. Every projected map needs a starting point, which is the latitude of origin. The engine requires this value to fall between negative 90 and 90 degrees. Still, you must express this value in the specific angular unit of that system.

Many teams trigger mysql error 4105 by mixing up latitude and longitude values. Longitude values can reach 180 degrees, which breaks the strict latitude limit. When a script swaps these two numbers, the database stops the query right away.

Unit mismatches also cause this error during data migrations. Your spatial system might use radians or gradians instead of standard degrees. If you pass a radian value that converts to over 90 degrees, the check fails. The database engine reads the angular unit first and then checks the origin bounds.

Bad imports from external geographic tools can also introduce broken definitions. Some mapping tools export raw projection text with out-of-bounds default placeholders. MySQL rejects these placeholders to keep your spatial calculations accurate and safe.

How to diagnose and fix the failure in production

Start by finding the exact statement that failed in your database error logs. Look at the spatial definition string inside the query that tried to create the system. Find the parameter that sets the latitude of origin for the map projection.

DPoP (Demonstration of Proof-of-Possession) + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Next, check the angular unit defined in that same spatial text string. Look at the conversion factor that turns your custom unit into standard degrees. Multiply your origin value by this factor to see the real degree value. If the result is below negative 90 or above 90, you found the bug.

Update your migration script with a number that fits inside the valid range. Double-check that your team did not swap the latitude and longitude fields by mistake. Test the updated spatial definition in a staging database before you run it in production.

Preventing spatial errors without granting excessive privileges

Modifying spatial reference systems requires high database privileges in MySQL. Do not give these broad permissions to every developer or app account. Instead, run spatial updates through a strict review process with limited roles.

Keep your spatial definitions in version control alongside your standard schema changes. Add automated checks in your build pipeline to test coordinate bounds early. This practice catches bad math before a human runs the change in production.

When engineers inspect production data to debug spatial rows, protect sensitive columns as well. Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results. This lets your team check spatial records while keeping private user details safe.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.

With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

What does SQLSTATE SR002 mean in MySQL?

SQLSTATE SR002 means a spatial reference system definition contains an invalid geographic parameter. For error 4105, it points to an out-of-bounds latitude of origin value.

Can I use radians for the latitude of origin?

Yes, you can use radians if your spatial system defines radians as the angular unit. The radian value must still equal between negative 90 and 90 degrees after conversion.

Does mysql error 4105 corrupt existing spatial tables?

No, this error stops the bad spatial definition before the engine saves it. Your existing tables and geometry rows remain safe and unchanged.

The query runs. The emails stay hidden.