I recently created a MySQL table with a column of type GEOMETRY.
When I back up the table with mysqldump, it outputs my geometry column as a quoted string, containing some escaped characters like \0, and also some characters that look like raw binary bytes in the upper-ASCII range.
When I try to restore the dump to another database it fails with an error:
"Cannot get GEOMETRY object from the data you send to the Geometry field".
I tried adding --hex-blob to my command line but this does not change the output or fix the problem.
I'm sure someone didn't create a data type in MySQL and forget to include a way to back it up. What am I missing?
Thanks.
解决方案
In my case, this error appeared specifically with empty geometry values in a non-null geometry column.
In my case, the empty geometries were legitimate cases of unknown geometry, so I addressed this by changing the column to allow null values, and then running UPDATE ... SET geom = NULL WHERE IsEmpty(geom);
After this, I was able to re-run mysqldump and successfully import the resulting sql into a separate database.
(To be honest, I'm not sure how the empty geometry values got there in the first place - I don't even know the syntax to create an empty geometry value)