inet_aton() 点分十进制IP地址 -> 整型

inet_ntoa() ×××->点分十进制IP地址

 

mysql> select inet_aton('192.168.10.10');

+----------------------------+

| inet_aton('192.168.10.10') |

+----------------------------+

|                 3232238090 |

+----------------------------+

1 row in set (0.03 sec)


mysql> select inet_ntoa(3232238090);

+-----------------------+

| inet_ntoa(3232238090) |

+-----------------------+

| 192.168.10.10         |

+-----------------------+

1 row in set (0.00 sec)


附:计算方法

mysql> select (192*256*256*256+168*256*256+10*256+10);

+-----------------------------------------+

| (192*256*256*256+168*256*256+10*256+10) |

+-----------------------------------------+

|                              3232238090 |

+-----------------------------------------+

1 row in set (0.00 sec)