0

I ran the command as root:

set @@auto_increment_offset = 2;

But the effect cannot be seen from other connections. Why not? It is global.

From http://dev.mysql.com/doc/refman/5.1/en/replication-options-master.html: "If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted."

That doesn't seem to agree with what I am seeing.

Ultimately, I would like to know if there any way to permanently set the offset for all clients without restarting mysqld?

2
  • 2
    I was operating under the assumption that "set @@variable = x" is the same as "set global variable = x". Not true at all.
    – Fantius
    Aug 20, 2012 at 12:59
  • right! "set @@variable = x" is equivalent to "SET SESSION variable = x".
    – Omesh
    Aug 20, 2012 at 13:18

2 Answers 2

6

As per MySQL documentation you need to set values of auto_increment_offset for both GLOBAL and SESSION.

SET GLOBAL auto_increment_offset  = 2;
SET SESSION auto_increment_offset  = 2;

SHOW VARIABLES LIKE '%auto_increment_offset%';

If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted. If the local value is set, the new value affects AUTO_INCREMENT columns for all tables into which new rows are inserted by the current user for the duration of the session, unless the values are changed during that session.

4

To set it globally you should add prefix 'GLOBAL' or '@@global.'. For example -

SET @@GLOBAL.auto_increment_offset = 2;

The '@@' is the same as 'SESSION' or '@@session.', it sets session variable.

Using System Variables.

1
  • 3
    It also needs to be added to the configuration file to be truly permanent.
    – tadman
    Aug 20, 2012 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.