日期:2014-05-16  浏览次数:20767 次

mysql 自定义变量随mysql启动而生效
当我想要mysql的job服务时,我需要先执行:
SET GLOBAL event_scheduler = ON;
SET @@global.event_scheduler = ON;
SET GLOBAL event_scheduler = 1;
SET @@global.event_scheduler = 1;
而mysql重启后,这些变量值又需要重新去设置;

解决办法是在/etc/my.cnf 的[mysqld]段下添加自己想定义的变量,
那么它们就会随mysql启动而设置生效,如上述就是:
event_scheduler = 1

[root@west etc]# /etc/init.d/mysqld restart;
进入数据库命令行查看变量值:
mysql> show variables like '%schedule%';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| event_scheduler | ON    |
+-----------------+-------+
1 row in set (0.00 sec)