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.
Use the sed command on your bash shell to separate the data of the table that you want to restore. For example, if we want to restore only the “film_actor” table to “sakila” database we execute the script below.
You can do it very easily using MySQL GUI tools like SQLyog, PHPMyAdmin. In SQLyog you just need to select the table, Click on "Export As..." Icon and you will get dialog to select the columns that you want to Export. Then click on "Export Button". Export is done...
The LOAD DATA statement reads rows from a text file into a table at a very high speed. The file can be read from the server host or the client host, depending on whether the LOCAL modifier is given.
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)
Frank, this appears to be a long-standing (and still open) bug with mysqldump. See http://bugs.mysql.com/bug.php?id=43544.
As a workaround, you may be able to use the ogr2ogr tool to export the data to a shapefile, and then import it back into the database. See http://www.bostongis.com/PrinterFriendly.aspx?content_name=ogr_cheatsheet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With