SHOW VARIABLES LIKE 'event%'; -- 查看定时任务是否开启(off:关闭 on:开启) mysql
set global event_scheduler =1; -- 1:表明开启 0:表明关闭
sql
-- 查看Mysql系统变量 spa
SHOW VARIABLES;
日志
-- 设置慢查询时间(单位秒)
索引
set long_query_time = 2; it
-- 开启慢查询(5.1.19之前是log_slow_queries 5.1.19之后是:slow_query_log,5.1.21以前的版本,变量值只能设置为整,最小能够设置为1(秒),5.1.21以前能够设置小数,1.000002(1秒又2微妙))
io
set GLOBAL slow_query_log = ON; innodb
-- 设置日志表文件 event
set slow_query_log_file= d:\mysql_log\slow_log.log; table
-- 没有使用索引页记录慢日志
set global log_queries_not_using_indexes = ON;
[mysqld]
max_allowed_packet = 10M
设置 innodb_log_file_size 大小
[mysqld]
innodb_log_file_size = 200M
Caused BY: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: The size of BLOB/TEXT DATA inserted IN ONE TRANSACTION IS greater THAN 10% of redo LOG size. Increase the redo LOG size USING innodb_log_file_size. (innodb_log_file_size 设置太小,上传文件过大)
SHOW VARIABLES LIKE '%timeout%';
MYSQL默认interactive_timeout、wait_timeout时间:28800秒(8小时)
修改/etc/my.cnf 下为:
[mysqld]
interactive_timeout=28800000
wait_timeout=28800000
或临时设置
SET interactive_timeout=28800000;
SET wait_timeout=28800000;
my.cnf开启MYSQL慢查询
[mysqld]
long_query_time=2
log-slow-queries=d:\mysql_log\mysql_log.log
开启仍是要命令模式:
-- 开启慢查询
set GLOBAL slow_query_log = ON;
-- 没有使用索引页记录慢日志
set log_queries_not_using_indexes = ON;
4. 开启MYSQL(innodb)独立表空间
-- 开启Innodb表单个文件
[mysqld]
innodb_file_per_table=1
5. group_concat_max_len 设置
SET GLOBAL group_concat_max_len=102400;
SET SESSION group_concat_max_len=102400;