MySQL runs as a user or impersonates

In MySQL, is there a way to execute a query as a specific user to check table permissions? Is there a way to personalize the user's execution context when you are connected to a higher priority account?

In the MSSQL world, you can use EXECUTE AS login = 'username' and then your SQL statements and then finally REVERT to close the impersonation.

Is there something similar in MySQL?

+4
source share
2 answers

Personally, I have never tried it before, but you can take a look at the " Mysql Proxy User " starting with MySQL 5.5.7

The plugin can request the treatment of an external (external) user as another user for checking privileges. This allows an external user to be a proxy for the second user; that is, to have privileges of the second user. In other words, the external user is a "proxy user" (a user who can impersonate or become known as another user), and the second user is a "proxy user" (a user whose identity can be used by a proxy user)

You can also write your own proxy authentication plugins

... Here is another post explaining the behavior of " MySQL Proxy Users - SU Emulation "

+1
source

You must go to the home page, change the settings of the local instance or any other scheme that you use. There you need to change the username. If you want to run a query in which you are logged in with your credentials, and want to run another query with different credentials, then check the "proxy users" in MySQL.

Hope this helps.

0
source

Source: https://habr.com/ru/post/1501956/


All Articles