This article mainly shares with you a brief introduction to IP address storage in Mysql, hoping to help everyone.
1. For ip addresses, mysql database storage has two general formats: string and integer.
String varchar(20):”192.168.1.10”
Integer type int(10 ):3232235786
The conversion format is as follows:
# INET_ATON(expr) 给出一个作为字符串的网络地址的点地址表示,返回一个代表该地址数值的整数。地址可以是4或8比特地址。 mysql> select INET_ATON('192.168.1.10') ; +---------------------------+ | INET_ATON('192.168.1.10') | +---------------------------+ | 3232235786 | +---------------------------+ 1 row in set (0.00 sec) # INET_NTOA(expr) 给定一个数字网络地址 (4 或 8 比特),返回作为字符串的该地址的电地址表示。 mysql> Select INET_NTOA(3232235786); +-----------------------+ | INET_NTOA(3232235786) | +-----------------------+ | 192.168.1.10 | +-----------------------+ 1 row in set (0.30 sec)
The above is the detailed content of A brief introduction to ip address storage in Mysql. For more information, please follow other related articles on the PHP Chinese website!