<tfoot id='hi6JB'></tfoot>
    • <bdo id='hi6JB'></bdo><ul id='hi6JB'></ul>
    <legend id='hi6JB'><style id='hi6JB'><dir id='hi6JB'><q id='hi6JB'></q></dir></style></legend>

      <small id='hi6JB'></small><noframes id='hi6JB'>

    1. <i id='hi6JB'><tr id='hi6JB'><dt id='hi6JB'><q id='hi6JB'><span id='hi6JB'><b id='hi6JB'><form id='hi6JB'><ins id='hi6JB'></ins><ul id='hi6JB'></ul><sub id='hi6JB'></sub></form><legend id='hi6JB'></legend><bdo id='hi6JB'><pre id='hi6JB'><center id='hi6JB'></center></pre></bdo></b><th id='hi6JB'></th></span></q></dt></tr></i><div id='hi6JB'><tfoot id='hi6JB'></tfoot><dl id='hi6JB'><fieldset id='hi6JB'></fieldset></dl></div>

      在 MySQL 中存储 IPv6 地址

      时间:2023-06-02
      <legend id='PZ931'><style id='PZ931'><dir id='PZ931'><q id='PZ931'></q></dir></style></legend>
          <bdo id='PZ931'></bdo><ul id='PZ931'></ul>

            <tfoot id='PZ931'></tfoot>

              <small id='PZ931'></small><noframes id='PZ931'>

              <i id='PZ931'><tr id='PZ931'><dt id='PZ931'><q id='PZ931'><span id='PZ931'><b id='PZ931'><form id='PZ931'><ins id='PZ931'></ins><ul id='PZ931'></ul><sub id='PZ931'></sub></form><legend id='PZ931'></legend><bdo id='PZ931'><pre id='PZ931'><center id='PZ931'></center></pre></bdo></b><th id='PZ931'></th></span></q></dt></tr></i><div id='PZ931'><tfoot id='PZ931'></tfoot><dl id='PZ931'><fieldset id='PZ931'></fieldset></dl></div>
                  <tbody id='PZ931'></tbody>
                本文介绍了在 MySQL 中存储 IPv6 地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                正如需要支持 ipv6 的 inet_aton 和 inet_ntoa 函数",目前没有用于存储 IPv6 地址的 MySQL 功能.用于存储/插入的推荐数据类型/函数是什么?(我不打算将它们存储为字符串).我也不想将 IPv6 地址分成 2 个 INT.

                As has been requested in "ipv6-capable inet_aton and inet_ntoa functions needed", there is currently no MySQL function for storing IPv6 addresses. What would be the recommended data type/function for storing/inserting? (I don't intend to store them as a string). I also don't want to separate the IPv6 address into 2 INT's.

                推荐答案

                怎么样:

                BINARY(16)
                

                那应该足够有效了.

                目前没有在 MySQL 服务器中将文本 IPv6 地址从/到二进制转换的功能,如该错误报告中所述.您要么需要在您的应用程序中执行此操作,要么可能需要在 MySQL 服务器中创建一个 UDF(用户定义函数)来执行此操作.

                Currently there is no function to convert textual IPv6 addresses from/to binary in the MySQL server, as noted in that bug report. You either need to do it in your application or possibly make a UDF (User-Defined Function) in the MySQL server to do that.

                更新:

                MySQL 5.6.3 已支持 IPv6 地址,请参阅以下内容:"INET6_ATON(expr)".

                MySQL 5.6.3 has support for IPv6 addresses, see the following: "INET6_ATON(expr)".

                数据类型是 VARBINARY(16) 而不是我之前建议的 BINARY(16).唯一的原因是 MySQL 函数适用于 IPv6 和 IPv4 地址.BINARY(16) 适用于仅存储 IPv6 地址并节省一个字节.VARBINARY(16) 在处理 IPv6 和 IPv4 地址时应使用.

                The data type is VARBINARY(16) instead of BINARY(16) as I suggested earlier. The only reason for this is that the MySQL functions work for both IPv6 and IPv4 addresses. BINARY(16) is fine for storing only IPv6 addresses and saves one byte. VARBINARY(16) should be used when handling both IPv6 and IPv4 addresses.

                旧版本 MySQL 和 MariaDB 的实现,请参见以下内容:使用 IPV6 功能扩展 MYSQL 5".

                An implementation for older versions of MySQL and MariaDB, see the following: "EXTENDING MYSQL 5 WITH IPV6 FUNCTIONS".

                这篇关于在 MySQL 中存储 IPv6 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在 windows xampp 上在哪里更改 lower_case_table_names=2 的值 下一篇:在 MySQL 中加载数据 infile 的访问被拒绝

                相关文章

              • <small id='AYqHe'></small><noframes id='AYqHe'>

                <legend id='AYqHe'><style id='AYqHe'><dir id='AYqHe'><q id='AYqHe'></q></dir></style></legend>
                  <bdo id='AYqHe'></bdo><ul id='AYqHe'></ul>

              • <tfoot id='AYqHe'></tfoot>
              • <i id='AYqHe'><tr id='AYqHe'><dt id='AYqHe'><q id='AYqHe'><span id='AYqHe'><b id='AYqHe'><form id='AYqHe'><ins id='AYqHe'></ins><ul id='AYqHe'></ul><sub id='AYqHe'></sub></form><legend id='AYqHe'></legend><bdo id='AYqHe'><pre id='AYqHe'><center id='AYqHe'></center></pre></bdo></b><th id='AYqHe'></th></span></q></dt></tr></i><div id='AYqHe'><tfoot id='AYqHe'></tfoot><dl id='AYqHe'><fieldset id='AYqHe'></fieldset></dl></div>