简体   繁体   English

MySQL LOAD DATA INFILE主机查找

[英]MySQL LOAD DATA INFILE host lookup

I have a CSV file with a timestamp and a host IP address on each row. 我有一个CSV文件,每行都有一个时间戳和一个主机IP地址。

The table I would like to load this file into, additionally has a hostname column. 我想将此文件加载到的表中还有一个主机名列。

I am trying to load this data using LOAD DATA INFILE. 我正在尝试使用LOAD DATA INFILE加载此数据。 Is there a way I can lookup the hostname as the data is loaded into the table? 当数据加载到表中时,有什么方法可以查找主机名吗?

Also as a more general question, how can I lookup the hostname for any given IP address inside of a stored procedure, for example. 同样作为一个更普遍的问题,例如,如何在存储过程中查找任何给定IP地址的主机名。

Thanks. 谢谢。

I don't think there is any MySQL function to lookup the hostname for a given IP address. 我认为没有任何MySQL函数可以查找给定IP地址的主机名。 I would suggest loading the data first and then looking up and missing hostnames using a script written in PHP, Ruby, Python, or whatever. 我建议先加载数据,然后使用用PHP,Ruby,Python或任何其他语言编写的脚本查找和丢失主机名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM