How to do wildcard search for IP addresses using INET_ATON in MySQL?
问题 I found this method to store IP addresses in MySQL database as integer using INET_ATON: https://stackoverflow.com/a/5133610/4491952 Since IPv4 addresses are 4 byte long, you could use an INT (UNSIGNED) that has exactly 4 bytes: `ipv4` INT UNSIGNED And INET_ATON and INET_NTOA to convert them: INSERT INTO `table` (`ipv4`) VALUES (INET_ATON("127.0.0.1")); SELECT INET_NTOA(`ipv4`) FROM `table`; For IPv6 addresses you could use a BINARY instead: `ipv6` BINARY(16) And use PHP’s inet_pton and inet