View Full Version : Search and Replace?
06-15-2011, 05:16 PM
So I had some sites over on iPower, they were recently hacked (iPower, not my sites specifically) and I have moved the sites to a new host. Now the problem is that I have a lot of databases with the following string just about everywhere:
They claim they had run cleaner scripts to remove this, but it is still there. So I need a way to search and replace every table, cell, bit of a given database.
I'm a bit frustrated so I'm having trouble thinking straight on this issue :)
Any ideas are welcome.
06-15-2011, 10:33 PM
And the database is MySQL?
You can do this with the help of the INFORMATION_SCHEMA database.
You can ask it for all the tables in your own database:
select table_name from tables where table_schema = 'name of your database';
Then you can ask for all the columns in a given table:
select column_name, data_type from columns where table_schema='db name' and table_name='one of your tables'
and then you can go look in all the columns that are text or varchar or char (and are long enough to hold that text) in your actual tables and do a REPLACE that zaps that text.
Write a little script (PHP or whatever you are familiar with) to run through all the tables and all the columns that are of the right type.
06-16-2011, 01:11 AM
Thanks - I was thinking it was going to come down to that, just wanted to make sure I didn't miss the magic command documentation :)
I think you helped me on my last SQL q as well, posted here long ago.
I have a feeling it may not be so simple though. I'll update this when I know
06-16-2011, 01:25 AM
I'm not a PHP person. I could do this in Java or C++ or even VBScript (either in an ASP page or as a ".vbs" stand-alone file). It's not really hard. Just a bit tedious.
If you want a ".vbs" solution (the fastest to write, but slowest to run...but not much slower, since all the real work is done in MySQL), I could try it.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.