Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I grep through a mysql database?

Tags:

Looking for a nifty helper function/method for grepping through all defined tables, columns, stored procedures, etc, for a MySql database.

I had something similar for SQL Server.

like image 934
Aaron Fi Avatar asked Jan 16 '09 20:01

Aaron Fi


People also ask

What is grep in MySQL?

Common Resource Grep (crgrep) searches for table/column name and data matches and supports MySQL. http://sourceforge.net/projects/crgrep/ Also searches other hard to search resources like content buried in archives.

How do I search an entire database in MySQL?

Find data across a MySQL connection by using the text search feature on any number of tables and schemas. From the schema tree, select the tables, schemas, or both to search and then right-click the highlighted items and click Search Data Table from the context menu.

How do I create a search query in MySQL?

In the search grid, choose tables and views of interest or leave them all checked. To narrow down the MySQL search data scope, select the table, views, numeric, text type, and date columns checkboxes. To start the search, click the Find button or hit the Enter key from the keyboard.


2 Answers

mysqldump --compact --skip-extended-insert -u root -proot mydb | grep "interesting string"

like image 110
ykaganovich Avatar answered Sep 22 '22 11:09

ykaganovich


In the INFORMATION_SCHEMA database:

select * from columns WHERE TABLE_NAME LIKE '%tablename%' AND COLUMN_NAME LIKE '%columnname%' 

More info here: http://dev.mysql.com/doc/refman/5.0/en/information-schema.html

Ok, it doesn't completely answer your question but you should be able to put it together how you want from here.

like image 40
Sarel Botha Avatar answered Sep 18 '22 11:09

Sarel Botha