All pages
Powered by GitBook
1 of 1

Loading...

SET SESSION AUTHORIZATION

Impersonate another user for the current session. Learn how to assume the identity and privileges of another account for testing or administration.

This statement is available from MariaDB 12.0.

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 with an arbitrary definer.

  • In particular, this bypasses , , authentication, REQUIRE SSL checks, and so on.

  • Users are required to have the privilege.

  • Does not work inside , prepared statements and .

Examples

SELECT USER(), CURRENT_USER(), DATABASE();
stored procedure
account lock
expired password
SET USER
transactions
stored procedures
+--------------------+--------------------+------------+
| user()             | current_user()     | database() |
+--------------------+--------------------+------------+
| msandbox@localhost | msandbox@localhost | test       |
+--------------------+--------------------+------------+
1 row in set (0.000 sec)
SET SESSION AUTHORIZATION foo@localhost;
SELECT USER(), CURRENT_USER(), DATABASE();
+---------------+----------------+------------+
| user()        | current_user() | database() |
+---------------+----------------+------------+
| foo@localhost | foo@%          | NULL       |
+---------------+----------------+------------+