> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-session-authorization.md).

# SET SESSION AUTHORIZATION

{% hint style="info" %}
This statement is available from MariaDB 12.0.
{% endhint %}

Certain users can perform server actions as another user:

* This is implemented through the `SET SESSION AUTHORIZATION` statement.
* This permits everything that can be done in a [stored procedure](/docs/server/server-usage/stored-routines/stored-procedures.md) with an arbitrary definer.
* In particular, this bypasses [account lock](/docs/server/security/user-account-management/account-locking.md), [expired password](/docs/server/security/user-account-management/user-password-expiry.md), authentication, `REQUIRE SSL` checks, and so on.
* Users are required to have the [SET USER](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#set-user) privilege.
* Does not work inside [transactions](/docs/server/reference/sql-statements/transactions.md), prepared statements and [stored procedures](/docs/server/server-usage/stored-routines/stored-procedures.md).

### Examples

```sql
SELECT USER(), CURRENT_USER(), DATABASE();
```

```
+--------------------+--------------------+------------+
| user()             | current_user()     | database() |
+--------------------+--------------------+------------+
| msandbox@localhost | msandbox@localhost | test       |
+--------------------+--------------------+------------+
1 row in set (0.000 sec)
```

```sql
SET SESSION AUTHORIZATION foo@localhost;
SELECT USER(), CURRENT_USER(), DATABASE();
```

```
+---------------+----------------+------------+
| user()        | current_user() | database() |
+---------------+----------------+------------+
| foo@localhost | foo@%          | NULL       |
+---------------+----------------+------------+
```
