show global statsu

show_global_statsu

mysqladmin -u root -p extended-status

mysqladmin_global_status

mysqladmin extended-status と show global statsuは同じ結果が返ってくる。
が、mysqladmin extended-statusにはもう少し便利な利用方法がある。

基本的には、mysqladmin extended-status と show global statsuは絶対値を
表示するので、MYSQLを起動してからの累計した数値が表示される。
増分のみを確認したい場合は以下のようにコマンドを実行する事で対応する事が可能です。

-r (relativeで前回表示時点との差分を返す)
-i (intervalで指定した秒間隔ごとに表示する)

[root@colinux mysql]# mysqladmin extended-status -r -i 5 -p | grep Com_select
Enter password:
| Com_select | 1 |
| Com_select | 0 |
| Com_select | 0 |
| Com_select | 0 |
| Com_select | 1 |
| Com_select | 1 |
| Com_select | 0 |
| Com_select | 0 |
| Com_select | 1 |
| Com_select | 0 |
| Com_select | 5 |
| Com_select | 4 |
| Com_select | 0 |

mysqladmin_extgened_status

[root@colinux mysql]# mysqladmin extended-status -r -i 5 -p | grep Slow_queries
Enter password:
| Slow_queries | 0 |
| Slow_queries | 0 |
| Slow_queries | 0 |
| Slow_queries | 0 |
| Slow_queries | 0 |
| Slow_queries | 0 |
| Slow_queries | 0 |
| Slow_queries | 0 |
| Slow_queries | 0 |

mysql_admin_slowquery


MYSQL 稼動状態確認 (ローカル、リモート)

[root@colinux ~]# mysqladmin ping -h localhost -u root -p
Enter password:
mysqld is alive
[root@colinux ~]#

MYSQLサービス状態の確認

[root@colinux ~]# mysqladmin status -u root -ppassword
Uptime: 12793  Threads: 1  Questions: 77  Slow queries: 0  Opens: 18  Flush tabl
es: 1  Open tables: 4  Queries per second avg: 0.6
[root@colinux ~]#

MYSQLバージョン確認

[root@colinux bin]# mysqladmin version -u root -ppassword
mysqladmin  Ver 8.42 Distrib 5.1.30, for pc-linux-gnu on i686
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version          5.1.30
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /tmp/mysql.sock
Uptime:                 14 min 12 sec

Threads: 1  Questions: 12406  Slow queries: 0  Opens: 472  Flush tables: 2  Open
tables: 3  Queries per second avg: 14.561
[root@colinux bin]#

GRANTテーブルをリロード

[root@colinux bin]# mysqladmin flush-privileges -u root -ppassword
[root@colinux bin]#

————————————————————————————————–

————————————————————————————————–

create databasename   Create a new database
debug                 Instruct server to write debug information to log
drop databasename     Delete a database and all its tables
extended-status       Gives an extended status message from the server
flush-hosts           Flush all cached hosts
flush-logs            Flush all logs
flush-status          Clear status variables
flush-tables          Flush all tables
flush-threads         Flush the thread cache
flush-privileges      Reload grant tables (same as reload)
kill id,id,…        Kill mysql threads

ping                  Check if mysqld is alive
processlist           Show list of active threads in server
reload                Reload grant tables
refresh               Flush all tables and close and open logfiles
shutdown              Take server down
status                Gives a short status message from the server
start-slave           Start slave
stop-slave            Stop slave
variables             Prints variables available
version               Get version info from server

※ [root@colinux ~]# mysqladmin shutdown -u root -ppassword

mysqladminでローカルリモートサーバーのshutdownが可能。startオプション無し。
mysqlコマンドでは出来ません。

■ping Check if mysqld is alive
[root@localhost ~]$ mysqladmin ping -h localhost -u root -p
Enter password:
mysqld is alive
[root@localhost ~]$

■processlist Show list of active threads in server
[root@localhost ~]$ mysqladmin processlist -h localhost -u root -p
Enter password:
+——+——+—————–+—-+———+——+——-+——————+
| Id | User | Host | db | Command | Time | State | Info |
+——+——+—————–+—-+———+——+——-+——————+
| 3638 | root | localhost:37293 | | Query | 0 | | show processlist |
+——+——+—————–+—-+———+——+——-+——————+
[root@localhost ~]$

■reload Reload grant tables
[root@localhost ~]$ mysqladmin reload -h localhost -u root -p
Enter password:
[root@localhost ~]$

■refresh Flush all tables and close and open logfiles
[root@localhost ~]$ mysqladmin refresh -h localhost -u root -p
Enter password:
[root@localhost ~]$

■shutdown Take server down
[root@localhost ~]$ mysqladmin shutdown -h localhost -u root -p
Enter password:
[root@localhost ~]$

※注意 Startは出来ません。

■status Gives a short status message from the server
[root@localhost ~]$ mysqladmin status -h localhost -u root -p
Enter password:
Uptime: 90 Threads: 1 Questions: 1 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.11
[root@localhost ~]$

■start-slave Start slave
■stop-slave Stop slave
■variables Prints variables available
[root@localhost ~]$ mysqladmin variables -h localhost -u root -p
Enter password:
+———————————+———————————————————————–+
| Variable_name | Value |
+———————————+———————————————————————–+
| auto_increment_increment | 1 |
| auto_increment_offset | 1 |
| autocommit | ON |
| automatic_sp_privileges | ON |
| back_log | 50 |
| basedir | /usr/local/src/mysql-5.1.25-rc-linux-i686-icc-glibc23/ |
| big_tables | OFF |
| binlog_cache_size | 32768 |
| binlog_format | MIXED |
| bulk_insert_buffer_size | 8388608 |
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |

■version Get version info from server
[root@localhost ~]$ mysqladmin version -h localhost -u root -p
Enter password:
mysqladmin Ver 8.42 Distrib 5.1.25-rc, for redhat-linux-gnu on i686
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version 5.1.25-rc-log
Protocol version 10
Connection localhost via TCP/IP
TCP port 3306
Uptime: 3 min 19 sec

Threads: 1 Questions: 4 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.20
[root@localhost ~]$


■ mysqlクライアントを利用してのDB作成

mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| test |
+——————–+
3 rows in set (0.00 sec)

mysql> CREATE DATABASE DB01 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.04 sec)

mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| DB01 |
| mysql |
| test |
+——————–+
4 rows in set (0.00 sec)

mysql>

■ mysqladminコマンドを利用してのDB作成

[root@colinux ~]# mysqladmin -u root -ppassword CREATE DB02;

[root@colinux ~]# mysqlshow -u root -ppassword
+——————–+
|     Databases      |
+——————–+
| information_schema |
| DATABASE           |
| DB01               |
| DB02               |
| mysql              |
| test               |
+——————–+
[root@colinux ~]#

DBは作成されているが、文字コードや照合順序は?

mysql> show create database DB02;
+———-+—————————————————————+
| Database | Create Database                                               |
+———-+—————————————————————+
| DB02     | CREATE DATABASE `DB02` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+———-+—————————————————————+
1 row in set (0.00 sec)

※ 文字コードを設定し忘れた場合、ALTER DATABASE DB02 default character set=utf8; で変更可能。

mysql> SHOW COLLATION LIKE ‘utf8_%_ci’;

collation


MYSQLに接続して来ているユーザーの確認。
不要なプロセスは、他のDBと同様にkillコマンドでプロセスIDを指定して停止出来る。

━━━━━━━━━ show processlist ━━━━━━━━━━
mysql> show processlist;
+—-+——+———–+——+———+——+——-+——————+
| Id | User | Host | db | Command | Time | State | Info |
+—-+——+———–+——+———+——+——-+——————+
| 14 | root | localhost | NULL | Query | 0 | NULL | show processlist |
+—-+——+———–+——+———+——+——-+——————+
1 row in set (0.01 sec)

mysql> show full processlist;
+—-+——+———–+——+———+——+——-+———————–
+
| Id | User | Host | db | Command | Time | State | Info
|
+—-+——+———–+——+———+——+——-+———————–
+
| 14 | root | localhost | NULL | Query | 0 | NULL | show full processlist
|
+—-+——+———–+——+———+——+——-+———————–
+
1 row in set (0.00 sec)

mysql>

━━━━━━━━━ mysqladmin ━━━━━━━━━━

[root@colinux ~]# mysqladmin -u variable -ppassword processlist;
+—-+———-+———–+—-+———+——+——-+——————+
| Id | User | Host | db | Command | Time | State | Info |
+—-+———-+———–+—-+———+——+——-+——————+
| 11 | variable | localhost | | Query | 0 | | show processlist |
+—-+———-+———–+—-+———+——+——-+——————+
[root@colinux ~]# mysqladmin -u variable -ppassword kill 11
[root@colinux ~]#

processlist