# 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       |
+---------------+----------------+------------+
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-session-authorization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
