mysql数据库ip与字符串

Mysql自带的IP转换语句

  • inet_aton:将ip地址转换成数字型
  • inet_ntoa:将数字型转换成ip地址
//使用inet_aton函数,将字符串IP转换为整型;
mysql> select inet_aton('73.115.134.73') as ip;
+------------+
| ip         |
+------------+
| 1232307785 |
+------------+

//使用inet_ntoa函数,将整型IP转换为字符串;
mysql> select inet_ntoa(1232307785) as ip;
+---------------+
| ip            |
+---------------+
| 73.115.134.73 |
+---------------+
原文地址:https://www.cnblogs.com/javadongx/p/ip_int_varchar.html