Problem with inserting IP Addresses into mySQL
Posted by: Arthur Chan
Date: January 07, 2019 10:23PM

I am creating an IPAddress Vault for my apps, each of which is asssigned to some specific piece of h/w.
Ideally the range should be from 192.168.100.mmm all the way to 192.168.900.nnn
So, this is a snippet:

START TRANSACTION;
DROP TABLE IF EXISTS TestIP;
CREATE TABLE TestIP (IPAddress INT UNSIGNED
    , TestBy_ID INT NOT NULL
    , InsertDateTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    , PRIMARY KEY (IPAddress)
)   ENGINE=INNODB AUTO_INCREMENT= 10 CHARACTER SET utf8 COLLATE utf8_general_ci;
INSERT INTO TestIP(IPAddress
	, TestBy_ID
	, InsertDateTime)
VALUES(inet_aton('192.168.600.10'), 12345, default);
SELECT inet_ntoa(IPAddress), TestBy_ID, InsertDateTime FROM TestIP
COMMIT;

mySQL workbench cannot insert address range bigger than 192.168.250.mmm, throws following error:
Incorrect string value: ''192.168.260.10'' for function inet_aton, but okay for 192.168.250.10
Weird!

Options: ReplyQuote


Subject
Written By
Posted
Problem with inserting IP Addresses into mySQL
January 07, 2019 10:23PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.