content_image/831210.jpg content_image/831211.jpg content_image/831208.jpg content_image/831209.jpg
<img src='content_image/831210.jpg'>

• CURRENT_ROLE() 

-> 23786 

<img src='content_image/831211.jpg'>

## Warning 

Changing the session value of the pseudo_thread_id  system variable changes the value returned by the CONNECTION_ID()  function. 

Returns a utf8  string containing the current active roles for the current session, separated by commas, or NONE  if there are none. The value reflects the setting of the sql_quote_show_create  system variable. 

Suppose that an account is granted roles as follows: 

GRANT ’r1’, ’r2’ TO ’u1’@’localhost’; SET DEFAULT ROLE ALL TO ’u1’@’localhost’; 

In sessions for u1 , the initial CURRENT_ROLE()  value names the default account roles. Using SET ROLE  changes that: 

mysql> SELECT CURRENT_ROLE(); 

<img src='content_image/831208.jpg'>

mysql> SET ROLE ’r1’; SELECT CURRENT_ROLE(); 

<img src='content_image/831209.jpg'>

• CURRENT_USER , CURRENT_USER() 

Returns the user name and host name combination for the MySQL account that the server used to authenticate the current client. This account determines your access privileges. The return value is a string in the utf8  character set. 

The value of CURRENT_USER()  can differ from the value of USER() . 

mysql> SELECT USER(); -> ’davida@localhost’ mysql> SELECT * FROM mysql.user; ERROR 1044: Access denied for user ’’@’localhost’ to database ’mysql’ mysql> SELECT CURRENT_USER(); -> ’@localhost’ 

The example illustrates that although the client specified a user name of davida  (as indicated by the value of the USER()  function), the server authenticated the client using an anonymous user account (as 

