# The MySQL sys schema
A collection of views, functions and procedures to help MySQL administrators get insight in to MySQL Database usage.
There are install files available for 5.6 and 5.7 respectively. To load these, you must position yourself within the directory that you downloaded to, as these top level files SOURCE individual files that are shared across versions in most cases (though not all).
## Installation
The objects should all be created as the root user (but run with the privileges of the invoker).
For instance if you download to /tmp/mysql-sys/, and want to install the 5.6 version you should:
cd /tmp/mysql-sys/
mysql -u root -p < ./sys_56.sql
Or if you would like to log in to the client, and install the 5.7 version:
cd /tmp/mysql-sys/
mysql -u root -p
SOURCE ./sys_57.sql
Alternatively, you could just choose to load individual files based on your needs, but beware, certain objects have dependencies on other objects. You will need to ensure that these are also loaded.
### Generating a single SQL file
There is bash script within the root of the branch directory, called `generate_sql_file.sh`, that allows you to create a single SQL file from the branch.
This includes substitution parameters for the MySQL user to use, and whether to include or exclude `SET sql_log_bin` commands from the scripts. This is particularly useful for installations such as Amazon RDS, which do not have the root@localhost user, or disallow setting sql_log_bin.
When run, this outputs a file named such as `sys_<sys_version>_<mysql_version_identifier>_inline.sql`, i.e. `sys_1.2.0_56_inline.sql` is sys version 1.2.0, built for MySQL 5.6.
#### Options
* v: The version of MySQL to build the sys schema for, either '56' or '57'
* b: Whether to omit any lines that deal with sql_log_bin (useful for RDS)
* u: The user to set as the owner of the objects (useful for RDS)
* m: Whether to generate a mysql_install_db / mysqld --bootstrap formatted file
#### Examples
Generate a MySQL 5.7 SQL file that uses the 'mark'@'localhost' user:
./generate_sql_file.sh -v 57 -u "'mark'@'localhost'"
Generate a MySQL 5.6 SQL file for RDS:
./generate_sql_file.sh -v 56 -b -u CURRENT_USER
Generate a MySQL 5.7 bootstrap file:
./generate_sql_file.sh -v 57 -m
## Overview of objects
### Tables
#### sys_config
##### Description
Holds configuration options for the sys schema. This is a persistent table (using the `InnoDB` storage engine), with the configuration persisting across upgrades (new options are added with `INSERT IGNORE`).
The table also has two related triggers, which maintain the user that `INSERTs` or `UPDATEs` the configuration - `sys_config_insert_set_user` and `sys_config_update_set_user` respectively.
Its structure is as follows:
```SQL
+----------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+-------------------+-----------------------------+
| variable | varchar(128) | NO | PRI | NULL | |
| value | varchar(128) | YES | | NULL | |
| set_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| set_by | varchar(128) | YES | | NULL | |
+----------+--------------+------+-----+-------------------+-----------------------------+
```
Note, when functions check for configuration options, they first check whether a similar named user variable exists with a value, and if this is not set then pull the configuration option from this table in to that named user variable. This is done for performance reasons (to not continually `SELECT` from the table), however this comes with the side effect that once inited, the values last with the session, somewhat like how session variables are inited from global variables. If the values within this table are changed, they will not take effect until the user logs in again.
##### Options included
| Variable | Default Value | Description |
| ---------------------- | ------------- | ------------------------------------------------------------------------------ |
| statement_truncate_len | 64 | Sets the size to truncate statements to, for the `format_statement()` function |
### Views
Many of the views in the sys schema have both a command line user friendly format output, as well as tooling friendly versions of any view that contains formatted output duplicated as an x$ table.
The examples below show output for only the formatted views, and note where there is an x$ counterpart available.
#### host_summary / x$host_summary
##### Description
Summarizes statement activity, file IO and connections by host.
When the host found is NULL, it is assumed to be a "background" thread.
##### Structures (5.7)
```SQL
mysql> desc host_summary;
+------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| statements | decimal(64,0) | YES | | NULL | |
| statement_latency | text | YES | | NULL | |
| statement_avg_latency | text | YES | | NULL | |
| table_scans | decimal(65,0) | YES | | NULL | |
| file_ios | decimal(64,0) | YES | | NULL | |
| file_io_latency | text | YES | | NULL | |
| current_connections | decimal(41,0) | YES | | NULL | |
| total_connections | decimal(41,0) | YES | | NULL | |
| unique_users | bigint(21) | NO | | 0 | |
| current_memory | text | YES | | NULL | |
| total_memory_allocated | text | YES | | NULL | |
+------------------------+---------------+------+-----+---------+-------+
12 rows in set (0.15 sec)
mysql> desc x$host_summary;
+------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+---------------+------+-----+---------+-------+
| host | varchar(60) | YES | | NULL | |
| statements | decimal(64,0) | YES | | NULL | |
| statement_latency | decimal(64,0) | YES | | NULL | |
| statement_avg_latency | decimal(65,4) | YES | | NULL | |
| table_scans | decimal(65,0) | YES | | NULL | |
| file_ios | decimal(64,0) | YES | | NULL | |
| file_io_latency | decimal(64,0) | YES | | NULL | |
| current_connections | decimal(41,0) | YES | | NULL | |
| total_connections | decimal(41,0) | YES | | NULL | |
| unique_users | bigint(21) | NO | | 0 | |
| current_memory | decimal(63,0) | YES | | NULL | |
| total_memory_allocated | decimal(64,0) | YES | | NULL | |
+------------------------+---------------+------+-----+---------+-------+
12 rows in set (0.00 sec)
```
##### Example
```SQL
mysql> select * from host_summary;
+------+------------+-------------------+-----------------------+-------------+----------+-----------------+---------------------+-------------------+--------------+
| host | statements | statement_latency | statement_avg_latency | table_scans | file_ios | file_io_latency | current_connections | total_connections | unique_users |
+------+------------+-------------------+----------
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
mysql-workbench-community-6.3.4-winx64-noinstall (2000个子文件)
audiotest.au 27KB
MySQLWorkbench.exe.config 199B
WBControls.dll.config 187B
COPYING 18KB
rel11.cur 326B
view.cur 326B
rel1n.cur 326B
hand.cur 326B
note.cur 326B
magnify_region.cur 326B
routine.cur 326B
rubber.cur 326B
image.cur 326B
table.cur 326B
zoom_in.cur 326B
zoom_out.cur 326B
layer.cur 326B
relnm.cur 326B
data.db 3KB
mysql.parser.dll 38.39MB
wbpublic.be.dll 8.75MB
gdal.dll 5.5MB
wbprivate.be.dll 5.49MB
wbpublic.wr.dll 5.26MB
wbprivate.wr.dll 4.97MB
mforms.wr.dll 4.6MB
libmysql.dll 4.5MB
wb.model.editors.wbp.wr.dll 3.31MB
db.mysql.editors.wbp.wr.dll 3.3MB
python27.dll 2.82MB
db.mysql.sqlparser.grt.dll 2.24MB
libglib-2.0-0.dll 1.44MB
libxml2.dll 1.43MB
libcairo.dll 1.01MB
db.mysql.wbp.dll 1001KB
wb.printing.wbp.wr.dll 965KB
libiconv.dll 911KB
grt.dll 832KB
mysql.forms.dll 728KB
sqlite3.dll 651KB
Scintilla.dll 616KB
mysqlcppconn.dll 577KB
db.mysql.grt.dll 526KB
mysql.canvas.dll 471KB
db.mysql.editors.wbp.be.dll 424KB
libgobject-2.0-0.dll 395KB
libctemplate.dll 394KB
base.wr.dll 382KB
base.dll 313KB
db.mysql.parser.grt.dll 298KB
wb.model.grt.dll 291KB
WBControls.dll 269KB
db.mysql.editors.wbp.fe.dll 268KB
wb.mysql.import.grt.dll 257KB
db.search.wbp.dll 256KB
db.mysql.diff.reporting.wbp.dll 234KB
HtmlRenderer.dll 216KB
WbPlugins.dll 192KB
libpng.dll 173KB
pcre.dll 172KB
Aga.Controls.dll 146KB
wb.model.editors.wbp.be.dll 134KB
db.mysql.query.grt.dll 118KB
cdbc.dll 117KB
MySQLCsUtilities.dll 115KB
base.windows.dll 114KB
wb.model.editors.wbp.fe.dll 100KB
wb.model.snippets.wbp.dll 100KB
grt.db.fe.dll 89KB
sqlide.fe.dll 83KB
zlib.dll 77KB
libintl-8.dll 76KB
wb.printing.wbp.be.dll 76KB
wb.printing.wbp.fe.dll 76KB
libzip.dll 66KB
wb.utils.native.grt.dll 66KB
libgmodule-2.0-0.dll 63KB
libgthread-2.0-0.dll 48KB
wb.fabric.interface.grt.dll 47KB
db.grt.dll 28KB
mysql.exe 4.63MB
mysqldump.exe 4.59MB
MySQLWorkbench.exe 504KB
wbcopytables.exe 202KB
ogr2ogr.exe 135KB
ogrinfo.exe 109KB
python.exe 27KB
wbadminhelper.exe 17KB
MySQL.g 149KB
PyBanner048.gif 954B
MySQLWBPlugin.ico 281KB
MySQLWorkbenchDoc.ico 81KB
MySQLWorkbench.ico 43KB
sys_reports.js 19KB
LICENSE 707B
README.md 209KB
sakila_full.mwb 51KB
ps_easysetup_logo_enabled@2x.png 86KB
ps_easysetup_logo@2x.png 72KB
ps_overview@2x.png 69KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
wch2013
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页