-2

I've got about 50 databases on my server and I'm making a script in PHP which will search through them all (all of the tables and entries) for a specific piece of data i.e. my email admin@site.com, how might I go around doing this?

Is there a better way of simply just making a query for every database since that would bloat my code so much since i'd have to do 50 queries.

Basically I wish to search for a word in every database and table on my server.

Blaatpraat
  • 2,829
  • 11
  • 23
user3258734
  • 143
  • 1
  • 2
  • 8
  • You could just place variable with all table names and loop through them (using the same query with the new tablename every time) – Bono Feb 23 '15 at 14:13
  • INFORMATION_SCHEMA database might be helpful since it contains every table name and its columns, from there you can construct dynamic query to search for data you need. – insanebits Feb 23 '15 at 14:19

1 Answers1

0

Loop through all databases by using SHOW DATABASES

Getting list of tables, and fields in each, in a database will show you how to get all tables and columns of the database, with that you will be able to search the whole db. Watch the field types to avoid conflicts.

Community
  • 1
  • 1
Daniel
  • 795
  • 1
  • 10
  • 25