How to allow MySQL connections from IPv6 network range

I’m trying to set up MySQL database access for multiple devices on my IPv6 network. I know how to do this with IPv4 subnets using the standard host_ip/netmask notation, but I found out that MySQL doesn’t support this format for IPv6 addresses. My network uses IPv6 and I need to grant database access to all devices within a specific range without having to add each individual IPv6 address manually. What’s the proper way to configure MySQL user permissions for an entire IPv6 subnet? I’ve been looking through the documentation but can’t find a clear solution for this specific case.

MySQL doesn’t have native IPv6 subnet support like it does for IPv4 - this caught me off guard during last year’s migration. I ended up creating a stored procedure that generates individual host entries for the IPv6 range I needed. You calculate the range programmatically and run multiple GRANT statements in a loop. You can also use MySQL’s wildcard matching with ‘%’ on the host portion, but it’s less precise than proper subnet notation. For production, I’d set up connection pooling through a proxy server on a single IPv6 address, then grant access to just that proxy IP. Way better control and security than managing individual device permissions across a huge IPv6 range.

Hit this same problem when we moved our dev environment to IPv6. MySQL 8.0.23+ supports CIDR notation, so you can just use ‘user’@‘2001:db8::/32’ in your GRANT statements. Before that version, I had to hack around with underscores and percent signs to match parts of the IPv6 address. Another trick that worked - create a view in the mysql database mapping IPv6 ranges to user privileges, then reference it in your connection logic. The catch is older MySQL versions treat IPv6 addresses as strings for pattern matching, not actual network addresses.