How to search all MySQL tables for a string

If you need to find a string in a MySQL database (searching across all available tables), theres a couple of options for achieving this; the easiest is if you have phpMyAdmin installed in which case you can use the built in search functionality. If this isn't something you've got installed on your server the alternative is to download the file and search in your favourite editor. 

Search via PHPMyAdmin

PHPMyAdmin has a built in search feature that allows you to search multiple tables at the same time. To use it, login to PHPMyAdmin and go to the 'Search' tab. Enter the search term in the first field and set the critera type. If you want to search all tables and fields that may contain 'hello' then use a wildcard like so:

%hello%

You can also restrict the search to specific columns using the last field. 

Download and search the export

An alternative that may be useful depending on how you want to manipulate the data afterwards is to export the database and then you can perform standard string search searches in an editor.

To export a database via PHPMyAdmin use the export tab and click go with the default options. To do it via command line you can use the following:

mysqldump -u yourusername -p yourpassword yourdatabasename > outputfile.sql

Sign Up

NEXT: Count table rows using jquery

How to count table rows using jQuery.

comments powered by Disqus
Sign Up

Popular Tags

350x250

Need a web developer?

If you'd like to work with code synthesis on your next project get in touch via the contact page.