Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search text in fields in every table of a MySQL database

Tags:

mysql

I want to search in all fields from all tables of a MySQL database a given string, possibly using syntax as:

SELECT * FROM * WHERE * LIKE '%stuff%' 

Is it possible to do something like this?

like image 921
RSilva Avatar asked Mar 12 '09 16:03

RSilva


People also ask

How do I search an entire MySQL database?

If you are using MySQL Workbench, right click on the database schema and select "Search Table Data..." then fill out the form. This will search the entire database. When (or if) the results come up, click on the arrow to expand.


2 Answers

You could do an SQLDump of the database (and its data) then search that file.

like image 181
Dean Rather Avatar answered Oct 23 '22 20:10

Dean Rather


If you have phpMyAdmin installed use its 'Search' feature.

  • Select your DB
  • Be sure you do have a DB selected (i.e. not a table, otherwise you'll get a completely different search dialog)
  • Click 'Search' tab
  • Choose the search term you want
  • Choose the tables to search

I have used this on up to 250 table/10GB databases (on a fast server) and the response time is nothing short of amazing.

like image 32
Greg Lyon Avatar answered Oct 23 '22 19:10

Greg Lyon