mysql磁盘满
1. 查询二进制日志,并清除
mysql二进制日志 - 81 - 博客园 (cnblogs.com)
可配置日志保留时间,如下:
mysql>show variables like '%expire_logs_days%'; --mysql 5.7
mysql> show variables like '%binlog_expire_logs_seconds%' --mysql8.0可修改配置文件,让日志文件放到别处
2. 错误日志清除
步骤一 查看error日志位置
mysql>show variables like 'log_error';步骤二 查看error日志大小[root@mysqlhost01 data]# ll -h log.err步骤三 清空error日志echo "" > /usr/local/mysql57/mysql5730/data/log.err3. 大表的表碎片清理
查看碎片
select table_schema,table_name,
concat(round((data_length+index_length)/1024/1024/1024,2),'G') as tablesize_gb,table_rows from information_schema.tablesorder by tablesize_gb desc limit 5;整理碎片
optimize table table.name或重建表,会触发整理整理位置 alter table table_name engine=innodb;
5.临时表空间
ibtmp1这个文件,可修改配置,使临时表空间文件放到别处
6. 把表内容放到其他位置
InnoDB指定数据文件的位置
mysql> SHOW VARIABLES LIKE 'innodb_file_per_table'; #先检查一下配置变量
如果innodb_file_per_table值为OFF,可以动态修改:
set global innodb_file_per_table=1;
创建表,并指定位置
CREATE TABLE temp3
(empno smallint(4) not null,
) engine=innodb charset=utf8 data directory='/u01/mysql/temp/';(在windows平台目录分割用/)
浙公网安备 33010602011771号