DaJunkie DaJunkie - 1 year ago 111
SQL Question

Retrieve client ip address in mysql

I'm trying to get with a simple SQL statement the IP address of the client. I do not want to use PHP or other techniques. Only pure SQL. When I use


I get


When I use


I get


But how do I get the plain IP? Thanks a lot in advance.

Answer Source

You will only get the IP address of the client process communicating with MySQL. Assuming this is what you want:

select host from information_schema.processlist WHERE ID=connection_id();

Will give you the host name (or IP address if name resolution is not enabled, which it is usually not) connecting to the mysql server on the current connection.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download