1MYSQLMETAGREP(1) MySQL Utilities MYSQLMETAGREP(1)
2
3
4
6 mysqlmetagrep - Search Database Object Definitions
7
9 mysqlmetagrep [options] [pattern | server] ...
10
12 This utility searches for objects matching a given pattern on all the
13 servers specified using instances of the --server option. It produces
14 output that displays the matching objects. By default, the first
15 non-option argument is taken to be the pattern unless the --pattern
16 option is given. If the --pattern option is given, then all non-option
17 arguments are treated as connection specifications.
18
19 Internally, the utility generates an SQL statement for searching the
20 necessary tables in the INFORMATION_SCHEMA database on the designated
21 servers, and then executes it before collecting the result and printing
22 it as a table. Use the --sql option to have mysqlmetagrep display the
23 statement, rather than execute it. This can be useful if you want to
24 feed the output of the statement to another application, such as the
25 mysql client command-line tool.
26
27 The MySQL server supports two forms of patterns when matching strings:
28 SQL Simple Patterns (used with the LIKE operator) and POSIX Regular
29 Expressions (used with the REGEXP operator).
30
31 By default, the utility uses the LIKE operator to match the name (and
32 optionally, the body) of objects. To use the REGEXP operator instead,
33 use the --regexp option.
34
35 Note
36 Because the REGEXP operator does substring searching, it is
37 necessary to anchor the expression to the beginning of the string
38 if you want to match the beginning of the string.
39
40 To specify how to display output, use one of the following values with
41 the --format option:
42
43 · grid (default)
44
45 Display output in grid or table format like that of the mysql
46 client command-line tool.
47
48 · csv
49
50 Display output in comma-separated values format.
51
52 · tab
53
54 Display output in tab-separated format.
55
56 · vertical
57
58 Display output in single-column format like that of the \G command
59 for the mysql client command-line tool.
60 SQL Simple Patterns.PP The simple patterns defined by the SQL standard
61 consist of a string of characters with two characters that have special
62 meaning: % (percent) matches zero or more characters, and _
63 (underscore) matches exactly one character.
64
65 For example:
66
67 · 'john%'
68
69 Match any string that starts with 'john'.
70
71 · '%doe%'
72
73 Match any string containing the word 'doe'.
74
75 · '%_'
76
77 Match any string consisting of one or more characters.
78 POSIX Regular Expressions.PP POSIX regular expressions are more
79 powerful than the simple patterns defined in the SQL standard. A
80 regular expression is a string of characters, optionally containing
81 characters with special meaning.
82
83 Documenting these regular expressions goes beyond the scope of this
84 manual, but the full syntax is described in the MySQL manual[1] and
85 other locations, such as executing 'man regex' in your terminal.
86
87 · .
88
89 Match any character.
90
91 · ^
92
93 Match the beginning of a string.
94
95 · $
96
97 Match the end of a string.
98
99 · [axy]
100
101 Match a, x, or y.
102
103 · [a-f]
104
105 Match any character in the range a to f (that is, a, b, c, d, e, or
106 f).
107
108 · [^axy]
109
110 Match any character except a, x, or y.
111
112 · a*
113
114 Match a sequence of zero or more a.
115
116 · a+
117
118 Match a sequence of one or more a.
119
120 · a?
121
122 Match zero or one a.
123
124 · ab|cd
125
126 Match ab or cd.
127
128 · a{5}
129
130 Match five instances of a.
131
132 · a{2,5}
133
134 Match from two to five instances of a.
135
136 · (abc)+
137
138 Match one or more repetitions of abc.
139 OPTIONS.PP mysqlmetagrep accepts the following command-line options:
140
141 · --help
142
143 Display a help message and exit.
144
145 · --license
146
147 Display license information and exit.
148
149 · --body, -b
150
151 Search the body of stored programs (procedures, functions,
152 triggers, and events). The default is to match only the name.
153
154 · --character-set=<charset>
155
156 Sets the client character set. The default is retrieved from the
157 server variable character_set_client.
158
159 · --database=<pattern>
160
161 Look only in databases matching this pattern.
162
163 · --format=<format>, -f<format>
164
165 Specify the output display format. Permitted format values are grid
166 (default), csv, tab, and vertical.
167
168 · --object-types=<types>, --search-objects=<types>
169
170 Search only the object types named in types, which is a
171 comma-separated list of one or more of the values database,
172 trigger, user, routine, column, table, partition, event and view.
173
174 The default is to search in objects of all types.
175
176 · --pattern=<pattern>, -e=<pattern>
177
178 The pattern to use when matching. This is required when the first
179 non-option argument looks like a connection specification rather
180 than a pattern.
181
182 If the --pattern option is given, the first non-option argument is
183 treated as a connection specifier, not as a pattern.
184
185 · --regexp, --basic-regexp, -G
186
187 Perform pattern matches using the REGEXP operator. The default is
188 to use LIKE for matching. This affects the --database and --pattern
189 options.
190
191 · --server=<source>
192
193 Connection information for a server. Use this option multiple times
194 to search multiple servers.
195
196 To connect to a server, it is necessary to specify connection
197 parameters such as user name, host name, password, and either a
198 port or socket. MySQL Utilities provides a number of ways to
199 provide this information. All of the methods require specifying
200 your choice via a command-line option such as --server, --master,
201 --slave, etc. The methods include the following in order of most
202 secure to least secure.
203
204 · Use login-paths from your .mylogin.cnf file (encrypted, not
205 visible). Example : <login-path>[:<port>][:<socket>]
206
207 · Use a configuration file (unencrypted, not visible) Note:
208 available in release-1.5.0. Example :
209 <configuration-file-path>[:<section>]
210
211 · Specify the data on the command-line (unencrypted, visible).
212 Example : <user>[:<passwd>]@<host>[:<port>][:<socket>]
213
214
215 · --sql, --print-sql, -p
216
217 Print rather than executing the SQL code that would be executed to
218 find all matching objects. This can be useful to save the statement
219 for later execution or to use it as input for other programs.
220
221 · --ssl-ca
222
223 The path to a file that contains a list of trusted SSL CAs.
224
225 · --ssl-cert
226
227 The name of the SSL certificate file to use for establishing a
228 secure connection.
229
230 · --ssl-cert
231
232 The name of the SSL key file to use for establishing a secure
233 connection.
234
235 · --ssl
236
237 Specifies if the server connection requires use of SSL. If an
238 encrypted connection cannot be established, the connection attempt
239 fails. Default setting is 0 (SSL not required).
240
241 · --version
242
243 Display version information and exit.
244 NOTES.PP For the --format option, the permitted values are not case
245 sensitive. In addition, values may be specified as any unambiguous
246 prefix of a valid value. For example, --format=g specifies the grid
247 format. An error occurs if a prefix matches more than one valid value.
248
249 The path to the MySQL client tools should be included in the PATH
250 environment variable in order to use the authentication mechanism with
251 login-paths. This will allow the utility to use the my_print_defaults
252 tools which is required to read the login-path values from the login
253 configuration file (.mylogin.cnf). EXAMPLES.PP Find all objects with a
254 name that matches the pattern 't_' (the letter t followed by any single
255 character):
256
257 shell> mysqlmetagrep --pattern="t_" --server=john@localhost
258 +------------------------+--------------+--------------+-----------+
259 | Connection | Object Type | Object Name | Database |
260 +------------------------+--------------+--------------+-----------+
261 | john:*@localhost:3306 | TABLE | t1 | test |
262 | john:*@localhost:3306 | TABLE | t2 | test |
263 | john:*@localhost:3306 | TABLE | tm | test |
264 +------------------------+--------------+--------------+-----------+
265
266 To find all object that contain 't2' in the name or the body (for
267 routines, triggers, and events):
268
269 shell> mysqlmetagrep -b --pattern="%t2%" --server=john@localhost:3306
270 +------------------------+--------------+--------------+-----------+
271 | Connection | Object Type | Object Name | Database |
272 +------------------------+--------------+--------------+-----------+
273 | john:*@localhost:3306 | TRIGGER | tr_foo | test |
274 | john:*@localhost:3306 | TABLE | t2 | test |
275 +------------------------+--------------+--------------+-----------+
276
277 In the preceding output, the trigger name does not match the pattern,
278 but is displayed because its body does.
279
280 This is the same as the previous example, but using the REGEXP
281 operator. Note that in the pattern it is not necessary to add wildcards
282 before or after t2:
283
284 shell> mysqlmetagrep -Gb --pattern="t2" --server=john@localhost
285 +------------------------+--------------+--------------+-----------+
286 | Connection | Object Type | Object Name | Database |
287 +------------------------+--------------+--------------+-----------+
288 | root:*@localhost:3306 | TRIGGER | tr_foo | test |
289 | root:*@localhost:3306 | TABLE | t2 | test |
290 +------------------------+--------------+--------------+-----------+
291
292 PERMISSIONS REQUIRED.PP The user must have the SELECT privilege on the
293 mysql database.
294
296 Copyright © 2006, 2015, Oracle and/or its affiliates. All rights
297 reserved.
298
299 This documentation is free software; you can redistribute it and/or
300 modify it only under the terms of the GNU General Public License as
301 published by the Free Software Foundation; version 2 of the License.
302
303 This documentation is distributed in the hope that it will be useful,
304 but WITHOUT ANY WARRANTY; without even the implied warranty of
305 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
306 General Public License for more details.
307
308 You should have received a copy of the GNU General Public License along
309 with the program; if not, write to the Free Software Foundation, Inc.,
310 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
311 http://www.gnu.org/licenses/.
312
313
315 1. MySQL manual
316 http://dev.mysql.com/doc/mysql/en/regexp.html
317
319 For more information, please refer to the MySQL Utilities and Fabric
320 documentation, which is available online at
321 http://dev.mysql.com/doc/index-utils-fabric.html
322
324 Oracle Corporation (http://dev.mysql.com/).
325
326
327
328MySQL 1.5.6 09/15/2015 MYSQLMETAGREP(1)