tags:

views:

27

answers:

1

I am trying to get a list of hosts connected to a mysql server. How can i get this? What should i do after connecting to the mysql server.

Code snippets will really help.

Also whats the best api to use to connect to mysql using c++?

A: 

One way you could do it is to execute the query show processlist, which will give you a table with Id, User, Host, db, Command, Time, State and Info columns. Remember that your show processlist query will be part of the output.

Håvard S
when you say, 'show processlist' query will be part of the output, do you mean there can be more hosts than that? As in do you mean it will give only a part of the hosts connected?Running the 'show processlist' and querying for unique 'Host' wouldnt that do?
AJ
Yes, there can be any of hosts, depending on how many different client machines are connected to your MySQL instance at the time you run your query. The query will return _all_ processes, including yours (which was my point).The `Host` field shows the host name of the client connected to the process, so if you query for a unique host you will get only the results for that host, yes.
Håvard S