wp db search <search> <tables>

Finds a string in the database

Arguments

NameDescription
searchString to search for. The search is case-insensitive by default
tablesOne or more tables to search through for the string

Options

NameDescription
--networkSearch through all the tables registered to $wpdb in a multisite install
--all-tables-with-prefixSearch through all tables that match the registered table prefix, even if not registered on $wpdb. On one hand, sometimes plugins use tables without registering them to $wpdb. On another hand, this could return tables you don’t expect. Overrides –network
--all-tablesSearch through ALL tables in the database, regardless of the prefix, and even if not registered on $wpdb. Overrides –network and –all-tables-with-prefix
--before_context <num>Number of characters to display before the match
--after_context <num>Number of characters to display after the match
--regexRuns the search as a regular expression (without delimiters). The search becomes case-sensitive (i.e. no PCRE flags are added). Delimiters must be escaped if they occur in the expression. Because the search is run on individual columns, you can use the ^ and $ tokens to mark the start and end of a match, respectively
--regex-flags <regex-flags>Pass PCRE modifiers to the regex search (e.g. ‘i’ for case-insensitivity)
--regex-delimiter <regex-delimiter>The delimiter to use for the regex. It must be escaped if it appears in the search string. The default value is the result of chr(1)
--table_column_onceOutput the ‘table:column’ line once before all matching row lines in the table column rather than before each matching row
--one_linePlace the ‘table:column’ output on the same line as the row id and match (‘table:column:id:match’). Overrides –table_column_once
--matches_onlyOnly output the string matches (including context). No ‘table:column’s or row ids are outputted
--statsOutput stats on the number of matches found, time taken, tables/columns/rows searched, tables skipped
--table_column_color <table_column_color>Percent color code to use for the ‘table:column’ output. For a list of available percent color codes, see below. Default ‘%G’ (bright green)
--id_color <id_color>Percent color code to use for the row id output. For a list of available percent color codes, see below. Default ‘%Y’ (bright yellow)
--match_color <match_color>Percent color code to use for the match (unless both before and after context are 0, when no color code is used). For a list of available percent color codes, see below. Default ‘%3%k’ (black on a mustard background)