[英]How to update BLOB values (MySQL file) with a script?
I have an SQL file that contains some BLOB values in some columns. 我有一个SQL文件,在某些列中包含一些BLOB值。
Using sed , I tried to find and replace all values that contain " https://example.com " to "localhost:8888/example" but it doesn't seem to work. 使用sed ,我试图找到并将包含“ https://example.com ”的所有值替换为“localhost:8888 / example”,但它似乎不起作用。
sed -i '.bak' 's/https:\/\/example\.com/localhost:8888\/example/g' db_file.sql
any ideas on how to update values in a "BLOB" ? 关于如何更新“BLOB”中的值的任何想法?
For example, I have in one of the columns a blob that, when read as text, is the following : 例如,我在其中一列中有一个blob,当作为文本读取时,如下所示:
s:20:"https://example.com";
to be transformed into : 转化为:
s:20:"localhost:8888/example";
That looks like php serialized data, the s
means its a string and the 20 is the length of the string, so you'll have to change the length as well with the replace. 这看起来像是php序列化数据,
s
表示它是一个字符串而20是字符串的长度,所以你必须改变长度以及替换。
So the replacement would be something like 所以替换就像是
s:22:"localhost:8888/example";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.