Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 383
Craig Stewart Avatar asked Nov 27 '11 02:11

Craig Stewart


People also ask

How do I find MySQL host and port?

Another way to find out the port which MySQL Server is using on Windows is , Go to my. ini file that is MySQL configuration file and you can check the port. To find the my. ini file for MySQL Server, you can go to services and then go to properties.

How can I see MySQL database in CMD?

To access a specific database, type the following command at the mysql> prompt, replacing dbname with the name of the database that you want to access: Copy use dbname; Make sure you do not forget the semicolon at the end of the statement. After you access a database, you can run SQL queries, list tables, and so on.

How do I see my MySQL database?

Show MySQL Databases The most common way to get a list of the MySQL databases is by using the mysql client to connect to the MySQL server and run the SHOW DATABASES command. If you haven't set a password for your MySQL user you can omit the -p switch.


1 Answers

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

like image 109
ajreal Avatar answered Oct 17 '22 10:10

ajreal