linux:ubuntu_mysql_clear_ib_logfiles
MySQL Clear Ib Logfiles
When shutting down MySQL InnoDB it can shut down in 3 ways:
- InnoDB will clean up old and redundant data and perform insert buffer merge before shutting down.
- A fast shutdown which skips the above tasks. It’s also the default one.
- Performs a controlled “crash”.
It is important that it is set to either 0 or 1 You can check it by doing the following query
SHOW GLOBAL VARIABLES LIKE 'innodb_fast_shutdown';
If this returns either 0 or 1 you are good to proceed. If you need to set it to either 0 or 1 you can do it like this.
SET GLOBAL innodb_fast_shutdown=1;
Next stop MySQL
systemctl stop mysql
Check the logfiles just in case MySQL did not shut down nicely.
Now move the logfiles out of the datadir i.e ib_logfile0, ib_logfile1 etc. (don't delete them just yet).
Once done start up MySQL again. InnoDB will notice there are no "REDO" log files and will create empty ones.
Purge Binlogs
Purge binlogs based on binlog number.
PURGE BINARY LOGS TO 'BINLOG.015689';
Purge binlogs based on date.
PURGE BINARY LOGS BEFORE '2013-08-24 00:06:00';
Alternate method not recomended but can be used as a last resort.
stop MySQL manally delete the mysql-bin binary log files systemctl start mysql
linux/ubuntu_mysql_clear_ib_logfiles.txt · Last modified: 24/11/2023 12:23 by Allan