复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347MYSQL ADMIN的学习 MYSQLADMIN的功能很多, 下面我们主要看下哪些功能是常用的吧。 1. 修改ROOT密码 [root@mysql_source ~]# mysqladmin -uroot -p password 'xg123' Enter password: [root@mysql_source ~]# mysql -uroot -pxg123 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 352 Server version: 5.5.37-log Source distribution Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. (testing)root@localhost [(none)]> 2. 查看当前版本以及数据库的一个大概运行情况: [root@mysql_source ~]# mysqladmin -uroot -p version Enter password: mysqladmin Ver 8.42 Distrib 5.1.61, for unknown-linux-gnu on x86_64 Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 5.5.37-log Protocol version 10 Connection Localhost via UNIX socket UNIX socket /tmp/mysql.sock Uptime: 13 hours 47 min 0 sec Threads: 1 Questions: 4805035 Slow queries: 8 Opens: 384 Flush tables: 1 Open tables: 27 Queries per second avg: 96.836 3. 查看MYSQL当前运行情况 [root@mysql_source ~]# mysqladmin -uroot -p status Enter password: Uptime: 49707 Threads: 1 Questions: 4805037 Slow queries: 8 Opens: 384 Flush tables: 1 Open tables: 27 Queries per second avg: 96.667 4. 查看MYSQL是否存活。 [root@mysql_source ~]# mysqladmin -uroot -p ping Enter password: mysqld is alive 5. 查看MYSQL详细的运行情况 [root@mysql_source ~]# mysqladmin -uroot -p extended-status Enter password: +------------------------------------------+-------------+ | Variable_name | Value | +------------------------------------------+-------------+ | Aborted_clients | 1 | | Aborted_connects | 1 | | Binlog_cache_disk_use | 0 | | Binlog_cache_use | 2986419 | | Binlog_stmt_cache_disk_use | 0 | | Binlog_stmt_cache_use | 0 | | Bytes_received | 4704268399 | | Bytes_sent | 4471316943 | | Com_admin_commands | 2 | ......还有很多。 这个参数还可以做很多事情,如: mysqladmin -uroot -p -r -i 1 ext | awk -F"|" "BEGIN{ count=0; }" '{ if($2 ~ /Variable_name/ && ++count == 1){ print "----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --"; print "---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical"; } else if ($2 ~ /Queries/){queries=$3;} else if ($2 ~ /Com_select /){com_select=$3;} else if ($2 ~ /Com_insert /){com_insert=$3;} else if ($2 ~ /Com_update /){com_update=$3;} else if ($2 ~ /Com_delete /){com_delete=$3;} else if ($2 ~ /Innodb_rows_read/){innodb_rows_read=$3;} else if ($2 ~ /Innodb_rows_deleted/){innodb_rows_deleted=$3;} else if ($2 ~ /Innodb_rows_inserted/){innodb_rows_inserted=$3;} else if ($2 ~ /Innodb_rows_updated/){innodb_rows_updated=$3;} else if ($2 ~ /Innodb_buffer_pool_read_requests/){innodb_lor=$3;} else if ($2 ~ /Innodb_buffer_pool_reads/){innodb_phr=$3;} else if ($2 ~ /Uptime / && count >= 2){ printf(" %s |%9d",strftime("%H:%M:%S"),queries); printf("|%6d %6d %6d %6d",com_select,com_insert,com_update,com_delete); printf("|%6d %8d %7d %7d",innodb_rows_read,innodb_rows_inserted,innodb_rows_updated,innodb_rows_deleted); printf("|%10d %11dn",innodb_lor,innodb_phr); }}' ----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read -- ---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical 10:58:17 | 1| 0 0 0 0| 0 0 0 0| 0 0 10:58:18 | 1| 0 0 0 0| 0 0 0 0| 0 0 10:58:19 | 1| 0 0 0 0| 0 0 0 0| 0 0 10:58:20 | 1| 0 0 0 0| 0 0 0 0| 0 0 10:58:21 | 1| 0 0 0 0| 0 0 0 0| 0 0 10:58:22 | 1| 0 0 0 0| 0 0 0 0| 0 0 10:58:23 | 1| 0 0 0 0| 0 0 0 0| 0 0 可以看到这么些信息。 还是很详细的吧,可以看到QPS, TPS, 操作行以及BUFFER POOL READ的情况 这段内容出自于orczhou的BLOG。 6. 查看参数值。 [root@mysql_source ~]# mysqladmin -uroot -p var | grep innodb_log_buffer_size Enter password: | innodb_log_buffer_size | 8388608 7. 查看当前的PROCESS [root@mysql_source ~]# mysqladmin -uroot -p processlist Enter password: +-----+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-----+------+-----------+----+---------+------+-------+------------------+ | 363 | root | localhost | | Query | 0 | | show processlist | 8. 创建数据库 [root@mysql_source ~]# mysqladmin -uroot -p create testdb Enter password: [root@mysql_source ~]# mysql -uroot -p -S /tmp/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 365 Server version: 5.5.37-log Source distribution Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. (testing)root@localhost [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | testdb | +--------------------+ 9. DROP DATABASE; [root@mysql_source ~]# mysqladmin -uroot -p drop testdb Enter password: Dropping the database is potentially a very bad thing to do. Any data stored in the database will be destroyed. Do you really want to drop the 'testdb' database [y/N] y Database "testdb" dropped [root@mysql_source ~]# mysql -uroot -p -S /tmp/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 367 Server version: 5.5.37-log Source distribution Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. (testing)root@localhost [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.01 sec) 10. 加载和刷新权限表。 [root@mysql_source ~]# mysqladmin -uroot -p reload Enter password: [root@mysql_source ~]# mysqladmin -uroot -p refresh Enter password: 11. 关闭数据库 [root@mysql_source ~]# mysqladmin -uroot -p shutdown Enter password: [root@mysql_source ~]# ps -elf | grep mysql 0 S root 23135 23043 0 80 0 - 25822 pipe_w 12:39 pts/2 00:00:00 grep mysql 12. KILL会话 [root@mysql_source ~]# mysqladmin -uroot -p processlist Enter password: +-----+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-----+------+-----------+----+---------+------+-------+------------------+ | 370 | root | localhost | | Sleep | 37 | | | | 373 | root | localhost | | Query | 0 | | show processlist | +-----+------+-----------+----+---------+------+-------+------------------+ [root@mysql_source ~]# mysqladmin -uroot -p kill 370 Enter password: [root@mysql_source ~]# mysqladmin -uroot -p processlist Enter password: +-----+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-----+------+-----------+----+---------+------+-------+------------------+ | 375 | root | localhost | | Query | 0 | | show processlist | +-----+------+-----------+----+---------+------+-------+------------------+ 当然还有更多更多的功能, 这里就不再一一列举了,把一些常用的东西记上, 以供查询。
转载于:https://www.cnblogs.com/o-to-s/articles/3781886.html
最后
以上就是典雅大船最近收集整理的关于MYSQLADMIN的使用的全部内容,更多相关MYSQLADMIN内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复