MySQL以用户身份执行或模拟

MySQL中,有没有办法以特定用户身份执行查询来测试表权限?当您与更高特权帐户连接时,有没有办法模拟用户执行上下文?

在MSSQL世界中,可以使用EXECUTE AS login =’username’,然后是SQL语句,最后是REVERT,以关闭模拟.

MySQL中有类似的东西吗?

最佳答案
我个人以前从未尝试过,但你可以看一下从MySQL 5.5.7开始的“Mysql Proxy User

The plugin may request that the connecting (external) user be treated
as a different user for privilege-checking purposes. This enables the
external user to be a proxy for the second user; that is, to have the
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 “proxied user” (a user whose identity
can be taken on by a proxy user)

你也可以自己编写authentication plugins for proxy users

……这里有另一篇解释这种行为的帖子“MySQL Proxy Users – SU emulation

转载注明原文:MySQL以用户身份执行或模拟 - 代码日志