简体   繁体   English

如何获取IP地址[MYSQL]

[英]How to get the IP address [MYSQL]

How can I get the IP address of mysql server running in the localhost machine? 如何获取在localhost机器上运行的mysql服务器的IP地址?

The following query returns 'localhost' because of name resolution. 由于名称解析,以下查询返回'localhost'。

   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? 那么需要做些什么来不考虑名称解析或是否有其他方式获取IP地址?

Thanks 谢谢

As for my knowledge you can't directly fetch the ip address of your localhost. 据我所知,你无法直接获取localhost的ip地址。 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. 但是mysql有一个utitlity,它存在于目录mysql\\bin其执行文件名是resolveip ,因为你可以像这样执行它。

resolveip localhost

In command prompt please give this by pointing your command prompt path to bin directory. 在命令提示符下,请将命令提示符路径指向bin目录。 For further detail about resolveip click me!!! 有关resolveip的更多详细信息, 请单击我!

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 这个函数是双向返回ie而不是解析名称,如果你给这样的IP地址

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. 如果您使用XAMPP并且无法直接调用resolveip Make sure you are inside the bin folder. 确保您在bin文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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