Cra*_*art 92 mysql sql database
Show Database
Use database
show tables
Describe <table>
Run Code Online (Sandbox Code Playgroud)
一切都很好,但有可能显示当前的连接主机.不是connection_id,而是主机的IP地址或名称.
ajr*_*eal 182
获取当前主机名: -
select @@hostname;
show variables where Variable_name like '%host%';
Run Code Online (Sandbox Code Playgroud)
获取所有传入请求的主机: -
select host from information_schema.processlist;
Run Code Online (Sandbox Code Playgroud)
根据您的上一条评论,
我认为您不能使用纯mysql函数解析主机名的IP,
因为它需要网络查找,这可能需要很长时间.
不过,mysql文档中提到了这个: -
resolveip google.com.sg
Run Code Online (Sandbox Code Playgroud)
docs: - http://dev.mysql.com/doc/refman/5.0/en/resolveip.html
show variables where Variable_name='hostname';
Run Code Online (Sandbox Code Playgroud)
那可以帮助你!
我想你试图让连接用户的远程主机...
您可以从命令中获取类似'myuser @ localhost'的字符串:
SELECT USER()
Run Code Online (Sandbox Code Playgroud)
您可以在"@"符号上拆分此结果,以获取部件:
-- delivers the "remote_host" e.g. "localhost"
SELECT SUBSTRING_INDEX(USER(), '@', -1)
-- delivers the user-name e.g. "myuser"
SELECT SUBSTRING_INDEX(USER(), '@', 1)
Run Code Online (Sandbox Code Playgroud)
如果您通过IP地址连接,您将获得ipadress而不是主机名.
归档时间: |
|
查看次数: |
180422 次 |
最近记录: |