PaulP
PaulP

Reputation: 43

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";

Upvotes: 3

Views: 451

Answers (1)

Musa
Musa

Reputation: 97717

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";

Upvotes: 1

Related Questions