In MySQL query:
SELECT host
FROM information_schema.processlist
WHERE ID = connection_id( )
LIMIT 0 , 30
The result of ^ this query is: localhost
.
SELECT @@hostname;
The result of ^ this query is: localhost
.
But I need to get ipaddress like 192.168.1.2
.
Question: How to get this result using mysql query?
MySQL. While MySQL doesn't have a data type for IP addresses, it's still easy to compare IPs in MySQL. Using inet_aton you can convert your IP addresses to integers before you compare.
To get the IP address only without the port number.
Select SUBSTRING_INDEX(host,':',1) as 'ip'
From information_schema.processlist
WHERE ID=connection_id();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With