简体   繁体   中英

How to get the IP address [MYSQL]

How can I get the IP address of mysql server running in the localhost machine?

The following query returns 'localhost' because of name resolution.

   Select SUBSTRING_INDEX(host,':',1) as 'ip' 
   From information_schema.processlist 
   WHERE ID=connection_id();

So what needs to be done to not take the name resolution into consideration or is there any other way of getting the IP address?

Thanks

As for my knowledge you can't directly fetch the ip address of your localhost. But mysql has utitlity which is present in directory mysql\\bin whose execution file name is resolveip for that you can execute it like this.

resolveip localhost

In command prompt please give this by pointing your command prompt path to bin directory. For further detail about resolveip click me!!!

It will return text output as like this

IP address of localhost is 127.0.0.1

This function is two way return ie Instead of resolved name if you give ip address like this

resolveip 127.0.0.1

It will return text output as like this

Host name of 127.0.0.1 is mypc.local, localhost

Or

./resolveip localhost 

In case you are using XAMPP and cannot call resolveip directly. Make sure you are inside the bin folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM