mysql 添加备份列,使用mysqldump备份带有GEOMETRY列的表?

当尝试使用mysqldump备份包含GEOMETRY类型的MySQL表时,遇到错误:"Cannot get GEOMETRY object from the data you send to the Geometry field"。问题出现在空几何值上。解决方案是将该列允许为空值,然后更新设置为空,再重新运行mysqldump,成功导入到另一个数据库。
摘要由CSDN通过智能技术生成

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)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值