23天学完mysql系统变量(一)

来源:互联网 发布:无线网卡不显示网络 编辑:程序博客网 时间:2024/06/10 00:37

一直以来我只关注mysql的比较重要的系统变量,这是不够的,所以我决定从今天起了解全部的系统变量,我想这是作为一个专业DBA应该具备的知识。

从A到W,每天学习以一个字母开头的变量。

今天就从A开始,以A开头的变量有四个,btw,我用的版本是5.5.19

auto_increment_increment 
auto_increment_offset
autocommit 
automatic_sp_privileges

1.auto_increment_increment 和 auto_increment_offset
这两个变量放到一起学习,因为他们都跟主-主复制有关,用来控制AUTO_INCREMENT列的。
默认值:都是1。
注意:
只支持NDB存储引擎

auto_increment_increment :     控制相邻两行的间隔值。
auto_increment_offset     :        决定auto_increment的起始值

例1:
mysql> show global variables like 'auto_increment%';
+--------------------------------------+---------+
| Variable_name                     | Value |
+--------------------------------------+---------+
| auto_increment_increment  |    1     |
| auto_increment_offset         |    1     |
+--------------------------------------+---------+
2 rows in set (0.00 sec)

当前设置,起始值和间隔值都是默认值1。

结果就会是这样:
+-----+| id  |+-----+|  1  ||  2  ||  3  ||  4  |+-----+
例2:
mysql> show global variables like 'auto_increment%';
+--------------------------------------+---------+
| Variable_name                     | Value |
+--------------------------------------+---------+
| auto_increment_increment  |    10   |
| auto_increment_offset         |    5     |
+--------------------------------------+---------+

当前设置起始值为5,间隔为10。

结果就会是这样:

+-----+| id  |+-----+|   5 ||  15 ||  25 ||  35 |+-----+


2.autocommit

默认值1,事务自动提交,这个没什么好说的。


3.automatic_sp_privileges
默认值1.这个变量跟存储例程有关。当创建一个存储例程时,mysql会自动授予创建存储例程的用户ALTER_ROUTINE和EXECUTE的权限。

ok,今天的学习任务完成。