HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Flush/Clean MySql ib_logfile0 ib_logfile1

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
ib_logfile1flushmysqlib_logfile0clean

Problem

Is there a way to flush ib_logfile0 and ib_logfile1 without dumping the tables to a .sql file, deleting, then re-inserting? Somebody entered a couple plain text credit card numbers into the customer notes table. It came up in my PCI scan and I removed them from the table but they still exist in the log files :(

Solution

You could have InnoDB clean things up as follows:

  • signal mysqld to have InnoDB flush everything out of the logs on shutdown



  • shutdown mysqld



  • delete the logs



  • start mysqld



No crash recovery will happen because there will be nothing to recover.

MYSQL_USER=root
MYSQL_PASS=rootpassword
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS} -h127.0.0.1 -P3306 --protocol=tcp"
SQL="SET GLOBAL innodb_fast_shutdown = 0"
mysql ${MYSQL_CONN} -ANe"${SQL}"
mysqladmin ${MYSQL_CONN} shutdown
cd /var/lib/mysql
rm -f ib_logfile*
service mysql start


If you want lingering data pages cleansed out of the Double Write Buffer, please see my old post Fill ibdata1 With Zeros/Nulls/etc Or Change A Table's Tablespace
GIVE IT A TRY !!!

Code Snippets

MYSQL_USER=root
MYSQL_PASS=rootpassword
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS} -h127.0.0.1 -P3306 --protocol=tcp"
SQL="SET GLOBAL innodb_fast_shutdown = 0"
mysql ${MYSQL_CONN} -ANe"${SQL}"
mysqladmin ${MYSQL_CONN} shutdown
cd /var/lib/mysql
rm -f ib_logfile*
service mysql start

Context

StackExchange Database Administrators Q#87692, answer score: 7

Revisions (0)

No revisions yet.