How to safely change MySQL innodb variable 'innodb_log_file_size'?

Yes it is safe to delete the log file once mysqld has been shutdown

In light of this, just perform the following steps:

mysql -uroot -p... -e"SET GLOBAL innodb_fast_shutdown = 0"
service mysql stop
mv /var/lib/mysql/ib_logfile[01] /tmp
service mysql start

Starting up mysqld will recreate ib_logfile0 and ib_logfile1

Give it a Try !!!

UPDATE 2011-10-20 16:40 EDT

It cleanly page out all data in the InnoDB Buffer Pool prior to redoing the Log Files, you should set this option about 1 hour before shutdown:

SET GLOBAL innodb_max_dirty_pages_pct = 0;

By default, innodb_max_dirty_pages_pct is 75 (MySQL 5.5+) or 90 (prior to MySQL 5.5). Setting this to zero keeps the number of dirty pages under 1% of the InnoDB Buffer Pool. Performing service mysql stop does this anyway. In addition, a shutdown will finish up any remaining items in the redo log. To keep to this option just add it to /etc/my.cnf:

[mysqld]
innodb_max_dirty_pages_pct = 0

UPDATE 2013-04-19 16:16 EDT

I updated my answer a little more with innodb_fast_shutdown because I used to restart mysql and stop mysql to do this. Now, this one-step is vital because every transaction uncommitted may have other moving parts within and outside of the InnoDB Transaction Logs (See InnoDB Infrastructure).

Please note that setting innodb_fast_shutdown to 2 would clean the logs out as well but more moving parts still exist and gets picked on Crash Recovery during mysqld's startup. Setting of 0 is best.


I would instead recommend the official method, which I reproduce here for convenience:

To change the number or the size of InnoDB log files in MySQL 5.6.7 or earlier, use the following instructions. The procedure to use depends on the value of innodb_fast_shutdown, which determines whether or not to bring the system tablespace fully up-to-date before a shutdown operation:

  • If innodb_fast_shutdown is not set to 2: Stop the MySQL server and make sure that it shuts down without errors, to ensure that there is no information for outstanding transactions in the redo log. Copy the old redo log files to a safe place, in case something went wrong during the shutdown and you need them to recover the tablespace. Delete the old log files from the log file directory, edit my.cnf to change the log file configuration, and start the MySQL server again. mysqld sees that no InnoDB log files exist at startup and creates new ones.

  • If innodb_fast_shutdown is set to 2: Set innodb_fast_shutdown to 1:

mysql> SET GLOBAL innodb_fast_shutdown = 1;

Then follow the instructions in the previous item.

As of MySQL 5.6.8, the innodb_fast_shutdown setting is no longer relevant when changing the number or the size of InnoDB log files. Additionally, you are no longer required remove old log files, although you may still want to copy the old log files to a safe place, as a backup. To change the number or size of InnoDB log files, perform the following steps:

  1. Stop the MySQL server and make sure that it shuts down without errors.

  2. Edit my.cnf to change the log file configuration. To change the log file size, configure innodb_log_file_size. To increase the number of log files, configure innodb_log_files_in_group.

  3. Start the MySQL server again.

If InnoDB detects that the innodb_log_file_size differs from the redo log file size, it will write a log checkpoint, close and remove the old log files, create new log files at the requested size, and open the new log files.


innodb_buffer_pool_size -- simply change my.cnf (my.ini) and restart mysqld.

innodb_log_file_size is less critical. Don't change it unless there is a reason to. Roland provided the steps, but one aspect worries me... I do not know if the first two steps are important; it seems like they could be:

  1. set innodb_fast_shutdown = OFF
  2. restart mysql
  3. stop mysql
  4. remove the logfiles
  5. start mysql

The log files keep track of unfinished business; "innodb_fast_shutdown" says to deal with that stuff after restarting. So removing the files may lose info?

New versions have improved things: (more discussion in Comments)

  • 5.6 Allows for innodb_log_file_size > 4GB
  • 5.6 innodb_log_file_size can be changed without first removing iblog*
  • 5.7 allows for dynamically resizing innodb_buffer_pool_size

Should I change log_file_size?

Use GLOBAL STATUS to compute the number of minutes before the log cycles.

Uptime / 60 * innodb_log_file_size / Innodb_os_log_written`

If it is much less than 60 (minutes), then it might help to increase log_file_size. If it is much more, then the log files are wasting disk space. That "1 hour" is rather arbitrary, so if you are close to it, do not bother changing the log_file_size.

Leave innodb_log_files_in_group at the default of 2.