MySQL显示当前连接信息 [英] MySQL show current connection info

查看:55
本文介绍了MySQL显示当前连接信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在MySQL终端会话中,但是我不知道我连接到哪个服务器,或者我连接到哪个数据库.

I am in a MySQL terminal session but I don't know what server I am connected to, or what database I am connected to.

是否有一条MySQL命令会告诉我我现在正在使用的主机,端口,用户名和数据库?

Is there a MySQL command that will tell me the host, port, and username and database I am using now?

推荐答案

您可以使用MYSQL函数.像这样解决用户的问题:

There are MYSQL functions you can use. Like this one that resolves the user:

SELECT USER();

这将返回类似root@localhost的内容,以便您获得主机和用户.

This will return something like root@localhost so you get the host and the user.

要获取当前数据库,请运行以下语句:

To get the current database run this statement:

SELECT DATABASE();

可以在这里找到其他有用的功能: http://dev.mysql.com/doc/refman/5.0/en/information-functions.html

Other useful functions can be found here: http://dev.mysql.com/doc/refman/5.0/en/information-functions.html

这篇关于MySQL显示当前连接信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆