有没有办法知道您当前在mysql中的用户名? [英] Is there a way to know your current username in mysql?

查看:92
本文介绍了有没有办法知道您当前在mysql中的用户名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道mysql查询是否可以返回发出查询的用户的用户名.

I would like to know if there's a way for a mysql query to return the username of the user that issues the query.

这可能吗?

推荐答案

尝试使用CURRENT_USER()函数.这将返回MySQL用来验证您的客户端连接的用户名.此用户名确定您的特权.

Try the the CURRENT_USER() function. This returns the username that MySQL used to authenticate your client connection. It is this username that determines your privileges.

这可能与客户端发送给MySQL的用户名不同(例如,即使您发送了用户名,MySQL可能仍使用匿名帐户对客户端进行身份验证).如果要使用客户端在连接时发送给MySQL的用户名,请使用USER()函数.

This may be different from the username that was sent to MySQL by the client (for example, MySQL might use an anonymous account to authenticate your client, even though you sent a username). If you want the username the client sent to MySQL when connecting use the USER() function instead.

该值表示您在连接到服务器时指定的用户名,以及从中连接的客户端主机.该值可以不同于CURRENT_USER()的值.

The value indicates the user name you specified when connecting to the server, and the client host from which you connected. The value can be different from that of CURRENT_USER().

http://dev.mysql. com/doc/refman/5.0/en/information-functions.html#function_current-user

这篇关于有没有办法知道您当前在mysql中的用户名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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