mysql: whoami?

后端 未结 3 1245
猫巷女王i
猫巷女王i 2021-02-06 21:15

Is there a whoami-like function in mysql?

I\'m connecting to the mysql command line from a remote host. I\'m not sure if my ip address is resolving to a do

相关标签:
3条回答
  • 2021-02-06 21:36

    If you are using mysql command line utility then try \s command:

    mysql> \s
    --------------
    mysql  Ver 14.12 Distrib 5.0.67, for suse-linux-gnu (i686) using readline 5.2
    
    Connection id:          519
    Current database:
    Current user:           admin@localhost
    .........
    Server version:         5.0.67 SUSE MySQL RPM
    .........
    
    0 讨论(0)
  • 2021-02-06 21:58

    You can use the CURRENT_USER and USER functions as follows:

    SELECT CURRENT_USER();
    
    SELECT USER();
    

    CURRENT_USER shows who you are authenticated as, while USER shows who you tried to authenticate as.

    See the MySQL manual for more information.

    0 讨论(0)
  • 2021-02-06 21:58

    Just do a...

    select user,host from mysql.user;
    

    Should show you what you want.

    0 讨论(0)
提交回复
热议问题