Warning
Error Code: 3713

MySQL Error 3713: Duplicate Spatial Reference System ID

📦 MySQL
📋

Description

This warning indicates an attempt to create a Spatial Reference System (SRS) using an SRID (Spatial Reference System Identifier) that is already assigned to another SRS. MySQL prevents the creation of duplicate SRIDs to maintain data integrity for spatial data.
💬

Error Message

There is already a spatial reference system with SRID %u.
🔍

Known Causes

3 known causes
⚠️
Direct SRID Conflict
Executing a `CREATE SPATIAL REFERENCE SYSTEM` statement with an SRID that is already present in the `mysql.st_spatial_reference_systems` table.
⚠️
Data Import Collision
Importing a database dump or running a script that includes SRS creation statements for SRIDs already existing in the target database.
⚠️
Application-Driven Duplication
An application or ORM attempts to define an SRS with an SRID that conflicts with an existing one during its initialization or operation.
🛠️

Solutions

3 solutions available

1. Identify and Remove Duplicate SRID medium

Locate the existing SRID definition and remove it before attempting to re-insert.

1
Connect to your MySQL server using a client like `mysql` command-line or MySQL Workbench.
2
Query the `mysql.spatial_ref_sys` table to find the existing entry with the problematic SRID. Replace `%u` with the actual SRID number from the error message.
SELECT * FROM mysql.spatial_ref_sys WHERE SRID = %u;
3
Once identified, delete the duplicate SRID entry. **WARNING:** Ensure you are deleting the correct entry to avoid data corruption.
DELETE FROM mysql.spatial_ref_sys WHERE SRID = %u;
4
Retry the operation that caused the error (e.g., `CREATE SPATIAL INDEX` or `ALTER TABLE ADD SPATIAL INDEX`).

2. Use a Different SRID easy

If the SRID is not critical, assign a new, unused SRID to avoid conflicts.

1
When defining your spatial column or creating a spatial index, choose an SRID that is not currently in use. You can check for existing SRIDs using the query from Solution 1.
2
Modify your `CREATE TABLE` or `ALTER TABLE` statement to use a different SRID. For example, if you were trying to use SRID 4326 and it's causing issues, try SRID 0 (no spatial reference) or another valid SRID if your data requires it.
ALTER TABLE your_table ADD COLUMN geom GEOMETRY SRID 0;
-- or --
CREATE SPATIAL INDEX index_name ON your_table (geom) USING SRID 0;
3
If you need a specific SRID (like 4326 for geographic coordinates), ensure it's properly registered in `mysql.spatial_ref_sys` as per Solution 3.

3. Register the SRID Correctly medium

If the SRID is genuinely needed and not a duplicate, ensure it's correctly registered in the system table.

1
Connect to your MySQL server.
2
Check if the SRID is already present in `mysql.spatial_ref_sys`. If it is, and you're still getting the error, there might be a deeper system issue or a corrupted entry. Proceed with Solution 1 in that case.
SELECT * FROM mysql.spatial_ref_sys WHERE SRID = %u;
3
If the SRID is not present, insert it into the `mysql.spatial_ref_sys` table. You'll need to provide the correct SRID value, the definition (e.g., `EPSG:4326`), and potentially other parameters. Consult the MySQL documentation for valid SRS definitions. For common SRIDs like EPSG:4326, you can use predefined values.
INSERT INTO mysql.spatial_ref_sys (SRID, auth_name, auth_srid, srtext, proj4text) VALUES (%u, 'EPSG', %u, 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],PRIMARY_KEY[10001,10001]]', '+proj=longlat +datum=WGS84 +no_defs');
-- Replace %u with the actual SRID number.
4
Retry the operation that caused the error.
🔗

Related Errors

5 related errors