Skip to content
Advertisement

Show MySQL host via SQL Command

Show Database
Use database
show tables
Describe <table>

All good and well, but is it possible to show the current connections host. Not connection_id, but the IP Address or Name of the host.

Advertisement

Answer

To get current host name :-

select @@hostname;
show variables where Variable_name like '%host%';

To get hosts for all incoming requests :-

select host from information_schema.processlist;

Based on your last comment,
I don’t think you can resolve IP for the hostname using pure mysql function,
as it require a network lookup, which could be taking long time.

However, mysql document mention this :-

resolveip google.com.sg

docs :- http://dev.mysql.com/doc/refman/5.0/en/resolveip.html

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement