简体   繁体   中英

How to update BLOB values (MySQL file) with a script?

I have an SQL file that contains some BLOB values in some columns.

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 -i '.bak' 's/https:\/\/example\.com/localhost:8888\/example/g' db_file.sql

any ideas on how to update values in a "BLOB" ?

For example, I have in one of the columns a blob that, when read as text, is the following :

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.
So the replacement would be something like

s:22:"localhost:8888/example";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM