在MySQL查询中:
SELECT host
FROM information_schema.processlist
WHERE ID = connection_id( )
LIMIT 0 , 30
此查询的结果为:localhost
。
SELECT @@hostname;
此查询的结果为:localhost
。
但是我需要像这样的ipaddress 192.168.1.2
。
问题: 如何使用mysql查询获得此结果?
仅获取IP地址而没有端口号。
Select SUBSTRING_INDEX(host,':',1) as 'ip'
From information_schema.processlist
WHERE ID=connection_id();
如果您在本地计算机上运行它,这还将解析名称“ localhost”。有获取IP的任何想法吗?