what should be the ideal size for storing IPv4, IPv6 addresses as a string in the MySQL database. should varchar(32) be sufficient?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming textual representation in a string :
xxx.xxx.xxx.xxxformat, 12+3separators)
Those are the maximum length of the string.
Alternatives to storing as string:
INT UNSIGNEDis common along withINET_ATONandINET_NTOAto handle the conversion from address to number, and from number to addressBIGINT(8 bytes), this however will use two fields.