Improve mysql_grant to work with IPv6.

This work attempts to improve the situation for matching IPv6
IP addresses, as the previous regex couldn't handle them properly.