PostgreSQL → MySQL
Convert PostgreSQL inet and network types to MySQL
PostgreSQL's network types (inet, cidr, macaddr) validate and sort IPs natively. MySQL stores them as text; validation moves to the application or CHECK constraints.
inet / cidr / macaddr → VARCHAR
What to know
- inet/cidr → VARCHAR(64), macaddr → VARCHAR(17) — text form preserved
- Range queries can use INET_ATON()/INET6_ATON() on the MySQL side
- For heavy IP analytics, store the binary form via INET6_ATON in VARBINARY(16)
- Subnet containment operators (<<=) have no MySQL equivalent — rewrite in app code
Before / after
PostgreSQL
ip inet
-- WHERE ip << '10.0.0.0/8' MySQL
ip VARCHAR(64)
-- WHERE INET_ATON(ip) BETWEEN INET_ATON('10.0.0.0')
-- AND INET_ATON('10.255.255.255') Don't convert column-by-column — convert the whole database.
Upload a dump, get back ready-to-import SQL with this mapping (and every other one) applied.
Open the PostgreSQL → MySQL converterSee the full type mapping table or all guides.