mysql 网站 数据库_mysql系统数据库
mysql系統(tǒng)數(shù)據(jù)庫(kù)主要存儲(chǔ)了一些存儲(chǔ)MySQL服務(wù)的系統(tǒng)信息表。一般情況下mysql庫(kù)的表都是MYASIM引擎,除非個(gè)別情況。mysql庫(kù)的表的作用大致可以分為以下幾類:
(1)授權(quán)系統(tǒng)表
(2)系統(tǒng)對(duì)象信息系統(tǒng)表
(3)日志系統(tǒng)表
(4)服務(wù)器端輔助系統(tǒng)表
(5)time zone系統(tǒng)表
(6)復(fù)制相關(guān)系統(tǒng)表
(7)optimizer相關(guān)系統(tǒng)表
(8)其他系統(tǒng)表,下面詳細(xì)看一看
下面詳細(xì)講:
一:授權(quán)系統(tǒng)表(Grant System Tables)
授權(quán)的一些表主要有以下幾個(gè):
user: User accounts, global privileges, and other non-privilege columns.
db:Database-level privileges.
tables_priv:Table-level privileges.
columns_priv:Column-level privileges.
procs_priv: Storedprocedure and function privileges.
proxies_priv: Proxy-user privileges.
基本上每一個(gè)系統(tǒng)表都會(huì)包含有權(quán)限列和范圍列,也就包含一些授權(quán)的主要信息表。
user表控制了用戶是否能夠連接,如果可以連接,則會(huì)指出此用戶的權(quán)限的信息,這個(gè)表適用于實(shí)例上的所有的數(shù)據(jù)庫(kù)。
db表范圍列決定哪些用戶可以訪問哪些數(shù)據(jù)庫(kù)從哪個(gè)主機(jī)。權(quán)限列決定允許的操作。在數(shù)據(jù)庫(kù)級(jí)別授予的權(quán)限適用于數(shù)據(jù)庫(kù)和數(shù)據(jù)庫(kù)中的所有對(duì)象,如表和存儲(chǔ)程序。
tables_priv和columns_priv表控制的權(quán)限就更為細(xì)致了,到了表級(jí)別和列級(jí)別。
procs_priv 表適用于存儲(chǔ)例程(過程和函數(shù))。在常規(guī)級(jí)別授予的權(quán)限只適用于一個(gè)單一的過程或函數(shù)。
proxies_priv 指出那個(gè)用戶可以作為代理,或者是用戶是否有權(quán)限給別的用戶代理權(quán)限。
二:系統(tǒng)對(duì)象信息系統(tǒng)表
event: event的系統(tǒng)表,每一次系統(tǒng)啟動(dòng)都會(huì)重新load一遍,除非指定 --skip-grant-tables參數(shù)啟動(dòng),不然都是要load的
func: 存放關(guān)于用戶定義的方法,除非指定 --skip-grant-tables參數(shù)啟動(dòng),不然每一次系統(tǒng)啟動(dòng)都會(huì)重新load一遍。
plugin: 存放有關(guān)服務(wù)器插件的相關(guān)信息,除非指定 --skip-grant-tables參數(shù)啟動(dòng),不然每一次系統(tǒng)啟動(dòng)都會(huì)重新load一遍。默認(rèn)的存儲(chǔ)引擎是INNODB
proc:存放存儲(chǔ)過程和方法的系統(tǒng)表。
三:日志系統(tǒng)表,一般情況下我看了看都是NULL的
general_log: The general query log table.
slow_log: The slow querylog table.
這兩張系統(tǒng)表可以將慢日志和日志按照表格的形式存儲(chǔ)下來,但是相對(duì)來說帶來對(duì)性能和存儲(chǔ)空間的使用更大,一般生產(chǎn)環(huán)境我們都建議設(shè)置為外部文件。
四:服務(wù)器端輔助系統(tǒng)表
help_category: Information about help categories.
help_keyword: Keywords associatedwithhelp topics.
help_relation: Mappingsbetween help keywords andtopics.
help_topic: Help topic contents.
這些表存儲(chǔ)了mysql幫助的基本信息,我們都可以用HELP +列 來查看具體的幫助信息。
例如:
五:time zone的相關(guān)系統(tǒng)表
time_zone: Time zone IDs and whether they useleap seconds.
time_zone_leap_second:Whenleap seconds occur.
time_zone_name: Mappingsbetween time zone IDs andnames.
time_zone_transition, time_zone_transition_type: Time zone descriptions.
設(shè)置時(shí)區(qū)用以下方式:SET GLOBAL time_zone = timezone;
可以用以下方式查看:SELECT @@global.time_zone, @@session.time_zone;
六:復(fù)制相關(guān)的表
gtid_executed: 存儲(chǔ)了復(fù)制執(zhí)行的GTID的信息。
ndb_binlog_index:
slave_master_info, slave_relay_log_info, slave_worker_info: 只有mysql作為slave的時(shí)候才會(huì)存儲(chǔ)相關(guān)信息
七:optimizer相關(guān)系統(tǒng)表
innodb_index_stats, innodb_table_stats: 顯示的是索引的信息
Table?15.3?Columns of innodb_table_stats
Column name
Description
database_name
Database name
table_name
Table name, partition name, or subpartition name
last_update
A timestamp indicating the last time that InnoDB updated this row
n_rows
The number of rows in the table
clustered_index_size
The size of the primary index, in pages
sum_of_other_index_sizes
The total size of other (non-primary) indexes, in pages
Table?15.4?Columns of innodb_index_stats
Column name
Description
database_name
Database name
table_name
Table name, partition name, or subpartition name
index_name
Index name
last_update
A timestamp indicating the last time that InnoDB updated this row
stat_name
The name of the statistic, whose value is reported in the stat_value column
stat_value
The value of the statistic that is named in stat_name column
sample_size
The number of pages sampled for the estimate provided in the stat_value column
stat_description
Description of the statistic that is named in the stat_name column
兩個(gè)表的last_update 這列都記錄了最后一次索引更改的時(shí)間。而且這兩張表都是可以手動(dòng)進(jìn)行更新的,修改這兩個(gè)表可以強(qiáng)制某個(gè)查詢的執(zhí)行計(jì)劃,或者測(cè)試替代計(jì)劃,優(yōu)點(diǎn)是不需要修改數(shù)據(jù)庫(kù)相關(guān)信息。更新統(tǒng)計(jì)信息需要使用FLUSH TABLE tbl_name來更新統(tǒng)計(jì)信息??梢圆樵兡硰埍淼乃饕畔?#xff1a;
SELECT SUM(stat_value) pages, index_name, SUM(stat_value)*@@innodb_page_size size FROM mysql.innodb_index_stats WHERE table_name=‘t1‘ AND stat_name = ‘size‘ GROUP BYindex_name;SELECT index_name, stat_name, stat_value, stat_description FROM mysql.innodb_index_stats WHERE table_name like ‘t1‘;SELECT index_name, stat_name, stat_value, stat_description FROM mysql.innodb_index_stats WHERE table_name like ‘t1‘ AND stat_name LIKE ‘n_diff%‘;
server_cost:服務(wù)器操作的成本估算信息
engine_cost: 指定存儲(chǔ)引擎的成本估算信息
FLUSH OPTIMIZER_COSTS命令可以重新開始讀取記錄信息。
八:其他的一些系統(tǒng)表
audit_log_filter, audit_log_user: 這兩個(gè)表提供的是mysql審計(jì)相關(guān)的信息,如果沒有安裝的話是沒有這兩個(gè)表的。
firewall_users, firewall_whitelist: 要安裝mysql企業(yè)防火墻才可以使用。
servers: 主要是 FEDERATED 引擎使用。不做介紹了。
這是一個(gè)mysql系統(tǒng)庫(kù)的大概介紹,感覺比較需要我們掌握的就是關(guān)于授權(quán),系統(tǒng)表,日志表,優(yōu)化表和復(fù)制相關(guān)的表。后面可以看一看mysql的日志類型等和優(yōu)化相關(guān)的方面深入了解一下。
總結(jié)
以上是生活随笔為你收集整理的mysql 网站 数据库_mysql系统数据库的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 硬盘写入速度_MySQL存储
- 下一篇: php mysql日期戳转时间戳_php