GotBatteries GotBatteries - 5 months ago 31
MySQL Question

MySQL - How to set auto_increment_increment permanently, to last server restart?

Is it possible to set MySQL auto_increment_increment so that it survives the server restart?

Currently I'm setting it like this:

SET @@auto_increment_increment=2;


But it loses the value when I:

sudo service mysql restart


And returns to default value of 1.

I'm on a AWS and I would like to be able to handle possible doomsday errors as easy as possible: by setting up a new instance from an AMI. I would like it to be ready to serve right away when it's up and avoid things like setting the auto_increment_increment -value by hand.

Answer

set it in my.ini or my.cnf

[mysqld]
auto_increment_increment = 2