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

Is it possible to change the MySQL server-id during a SQL session?

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

Problem

I have a MySQL 5.5 server with a server-id of 20. I want to execute a few queries on that server, but have them write to the binlog as a different server-id than 20. Is this possible?

I am aware set sql_log_bin is commonly used to turn binlogging on/off at-will, but I actually do want to execute these queries and have them written to the binlog, just as another server-id.

set server_id=21 errors saying it needs to be global, not a session variable, so I may already have my answer, but still, I have a feeling it is possible somehow. I mean, the mysql replication slave component can do it.

Solution

server_id is a dynamic variable, so you can change it while the server is running. To change the global variable, do:

SET GLOBAL server_id=21


More info at http://dev.mysql.com/doc/refman/5.5/en/replication-options.html#option_mysqld_server-id

Code Snippets

SET GLOBAL server_id=21

Context

StackExchange Database Administrators Q#43071, answer score: 8

Revisions (0)

No revisions yet.