MySQL replace string in column
Reading time: 0,4 min
Very useful when moving for example to a new domain. Imagine having thousands of posts with links you need to update
That's what happened to me. I have moved my blog's domain from tomsnews.net to tomsnews.io. Many posts have links to other posts. So I had to update them.
Of course MySQL Replace does much more than this. I hope you find it useful in your projects.
Here I just replace https://tomsnews.net with https://tomsnews.io in column posts_body.
UPDATE posts SET posts_body = REPLACE(posts_body,'https://tomsnews.net','https://tomsnews.io')