MySQL: Best way to store MAC addresses?

Nick picture Nick · Dec 23, 2010 · Viewed 20.9k times · Source

What's the best field type to use to store MAC addresses in a MySQL database? Also, should it be stored with a certain separator (colon or dash) or should it be stored without a separator?

Answer

Jon Black picture Jon Black · Dec 23, 2010

use bigint unsigned (8 bytes) then you can:

select hex(mac_addr) from log;

and

insert into log (mac_addr) values (x'000CF15698AD');