Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: Best way to store MAC addresses?

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?

like image 759
Nick Avatar asked Dec 22 '10 23:12

Nick


People also ask

How do you store your MAC address?

MAC addresses are primarily assigned by device manufacturers, and are therefore often referred to as the burned-in address, or as an Ethernet hardware address, hardware address, or physical address. Each address can be stored in hardware, such as the card's read-only memory, or by a firmware mechanism.

Where does MySQL store data on Mac?

By default, the MySQL directories are installed under /usr/local/ . Even better, add /usr/local/mysql/bin to your PATH environment variable. You can do this by modifying the appropriate startup file for your shell.

What data type is a MAC address?

The MAC address data type is an abstract data type and you cannot use it directly with standard C unary or binary operators. Only local or global variables of type mac_addr_t are supported. A variable of this type can also be stored in an associate array either as a key or as a value.

How do I manage MySQL on Mac?

Open macOS system preferences and select the MySQL preference panel, and then execute Start MySQL Server. The Instances page includes an option to start or stop MySQL, and Initialize Database recreates the data/ directory.


1 Answers

use bigint unsigned (8 bytes) then you can:

select hex(mac_addr) from log;

and

insert into log (mac_addr) values (x'000CF15698AD');
like image 66
Jon Black Avatar answered Sep 29 '22 17:09

Jon Black