mass find / replace in mysql?

Discussion in 'MySQL' started by carl_in_florida, Jul 11, 2007.

  1. #1
    I moved a wp install from one domain to another. I had a footer in the bottom of every post with a link. I need to change that footer in every post. Is there a way to do a mass find and replace in mysql?

    Thanks! I have found some answers on the web but I really don't understand them.
     
    carl_in_florida, Jul 11, 2007 IP
  2. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have had a similar problem in he past I just downloaded the SQL code (Export it from PHPMyAdmin or similar app) and open it in Wordpad or Notepad (Windows) and do a find and replace for the link code.

    This has worked for me in the past the only problem is that it sucks if the link is different in each footer (e.g. <a href="#" id="001">Link</a>) if id changes then you won't be able to replace them that easily.

    Then just save the SQL code and reinsert it into the DB (Note: You won't be able to just run the code you will have to empty the table first or else it will add onto the table)

    Sorry, I hope that was clear enough, if not let me know I will try to simplify lol ;)

    Hope this helps!

    Jeffrey
     
    jmhyer123, Jul 11, 2007 IP
  3. carl_in_florida

    carl_in_florida Active Member

    Messages:
    1,066
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    90
    #3
    /Here is what worked for me:

    UPDATE wp_posts SET post_content= REPLACE (
    post_content,
    'old footer here',
    'new footer here')
     
    carl_in_florida, Jul 11, 2007 IP
  4. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yeah, thats another way to do it ;)
     
    jmhyer123, Jul 12, 2007 IP