title: How to read IPv6 address stored as a varbinary in MySQL?
body: <p>I am storing IPv6 addresses as a <code>varbinary</code> with PHP function <code>inet_pton($_SERVER['REMOTE_ADDR'])</code>. When I run an SQL query such as:</p>
  
  <pre><code>SELECT ip_address FROM some_table WHERE id='some_id';
  </code></pre>
  
  <p>I wouldn't be able to read the ip_address because it is in a <code>binary</code> format.</p>
  
  <p>I notice that there is a corresponding MySQL function <code>INET6_NTOA(expr)</code> in <a href="http://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_inet6-ntoa" rel="nofollow noreferrer">MySQL version 5.6</a> to revert it back to readable format. Unfortunately, I am using MySQL version 5.5, which doesn't have that function.</p>
  
  <p>Is there any other way I can read the IPv6 addresses without going back to PHP to do the conversion? I can easily read off the hexadecimal notation of the binary string with the editor in the Workbench as shown in the image attached, so I thought there should be an easy way to do this.</p>
  
  <p><img src="https://i.stack.imgur.com/yHtbu.png" alt="enter image description here"></p>