MySQL INET6_NTOA() Function

In MySQL, the INET6_NTOA()

The INET6_NTOA() function is the inverse of the INET6_ATON() function.

INET6_NTOA() Syntax

Here is the syntax of the MySQL INET6_NTOA() function:

INET6_NTOA(ip)

Parameters

ip
Required. A numeric IPv6 or IPv4 address.

Return value

The MySQL INET6_NTOA() function converts the specified IPv6 or IPv4 address in numeric form to string form.

If the argument is NULL, the function will return NULL.

INET6_NTOA() Examples

Use INET6_NTOA() to process IPv6 addresses:

SELECT INET6_NTOA(UNHEX('FDFE0000000000005A55CAFFFEFA9089'));
+-------------------------------------------------------+
| INET6_NTOA(UNHEX('FDFE0000000000005A55CAFFFEFA9089')) |
+-------------------------------------------------------+
| fdfe::5a55:caff:fefa:9089                             |
+-------------------------------------------------------+

Here, we use the HEX() function to convert the returned binary string to hexadecimal characters.

Use INET6_NTOA() to process IPv4 addresses:

SELECT INET6_NTOA(UNHEX('C0A80164'));
+-------------------------------+
| INET6_NTOA(UNHEX('C0A80164')) |
+-------------------------------+
| 192.168.1.100                 |
+-------------------------------+