Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Created October 22, 2012 20:38
Show Gist options
  • Save dallasmarlow/3934017 to your computer and use it in GitHub Desktop.
Save dallasmarlow/3934017 to your computer and use it in GitHub Desktop.
consistent mysql server-id values based on mac address
# convert the last 4 octets of a mac address to base 10 for a numeric value between 0-4294967295 (which is the supported range for mysql's server-id)
# example mac address - "00:26:9E:2B:C7:36"
mac_address.split(':')[2..5].join.to_i(16)
# => 2653669174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment