C# 连接MySQL - 获取DB用户权限?

发布于 2024-08-09 15:10:46 字数 100 浏览 4 评论 0原文

我正在使用 System.data.odbc 与我的 MySQL 数据库进行通信。登录后,我需要知道用户是否是管理员,只是为了知道权限。有什么方法可以检索当前登录用户的权限吗? 谢谢你!

I am using System.data.odbc to communicate with my MySQL db. When logged, I would need to know whather the user is admin or not, just to know the rights. Is there any way how to retrieve rights of currently logged user?
Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼痛 2024-08-16 15:10:46

有一个SHOW命令来检索当前用户的授权:

SHOW GRANTS

如果您没有 SELECT 权限,SHOW GRANTS 将抛出错误:)

还有一个 INFORMATION_SCHEMA 表 您可以选择:

select * from information_schema.user_privileges

There's a SHOW command to retrieve the current user's grants:

SHOW GRANTS

If you don't have the SELECT privilege, SHOW GRANTS will throw an error :)

There's also an INFORMATION_SCHEMA table you can select from:

select * from information_schema.user_privileges
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文