gpt4 book ai didi

mysql - 使用 MySQL 查询获取 ip 地址

转载 作者:可可西里 更新时间:2023-11-01 06:34:02 24 4
gpt4 key购买 nike

在 MySQL 查询中:

SELECT host
FROM information_schema.processlist
WHERE ID = connection_id( )
LIMIT 0 , 30

^ 这个查询的结果是:localhost

SELECT @@hostname;

^ 这个查询的结果是:localhost

但我需要获取像192.168.1.2这样的ipaddress。

问题: 如何使用 mysql 查询得到这个结果?

最佳答案

只获取IP地址,不获取端口号。

 Select SUBSTRING_INDEX(host,':',1) as 'ip' 
From information_schema.processlist
WHERE ID=connection_id();

关于mysql - 使用 MySQL 查询获取 ip 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21777200/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com