How to search and replace on MYSQL?

Discussion in 'MySQL' started by TopDraw, Apr 9, 2007.

  1. #1
    Hi guys,

    Does someone know how to search & replace all instances of a word in the MYSQL using PHP My Admin (I believe)?

    I am having problems cleaning out my MYSQL database (Wordpress) of a old url and replace with another....its giving me a headache...cos there is 1300 instances of it...in the databse and this old url is screwing alot of things up

    Thanks for any answers
     
    TopDraw, Apr 9, 2007 IP
  2. tylerd

    tylerd Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Does this help?

    UPDATE TABLENAME SET FIELDNAME = 'NEWVALUE' WHERE (FIELDNAME = 'OLDVALUE')
     
    tylerd, Apr 10, 2007 IP
  3. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    phper, Apr 10, 2007 IP
  4. thebigsteveman

    thebigsteveman Active Member

    Messages:
    46
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    98
    #4
    I am trying a simpler way that I think will work.

    Go to the export tool and export the database so that you have it in a file that will be something like databasename.mysql

    Save a copy for back up purposes, then make a new copy which you will edit.

    Then take that new file you just saved, open it up in notepad, do a search and replace through the whole file, then import the database using the import tool.

    If you messed something up, you can still import the old database again.

    I am trying this right now because I have a similar problem. If this doesn't work, I'll let you know
     
    thebigsteveman, Aug 17, 2009 IP
  5. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What? Just use replace as mentioned above. How is your way easier??
     
    Goramba, Aug 21, 2009 IP
  6. johny321

    johny321 Member

    Messages:
    293
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #6
    Just use update command of SQl to replace items in the table
     
    johny321, Aug 25, 2009 IP
  7. ohmnifarious

    ohmnifarious Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thebigsteveman, were you successful in doing your global replace?
     
    ohmnifarious, Feb 4, 2010 IP
  8. tech_savvy

    tech_savvy Peon

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The first reply to your query should have solved your problem?
     
    tech_savvy, Feb 6, 2010 IP