How to store an IP in mySQL

前端 未结 7 510
情话喂你
情话喂你 2020-12-02 19:00

We\'ve got a healthy debate going on in the office this week. We\'re creating a Db to store proxy information, for the most part we have the schema worked out except for how

7条回答
  •  Happy的楠姐
    2020-12-02 19:29

    for both ipv4 and ipv6 compatibility, use VARBINARY(16) , ipv4's will always be BINARY(4) and ipv6 will always be BINARY(16), so VARBINARY(16) seems like the most efficient way to support both. and to convert them from the normal readable format to binary, use INET6_ATON('127.0.0.1'), and to reverse that, use INET6_NTOA(binary)

提交回复
热议问题