Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在考虑一些数据库管理系统,我的问题很简单:
是否有一种简单可靠的方法来通过 PHP 代码检索访问权限(写入、只读等)?
我还没有写任何代码,因为这只是我现在的想法,这只会帮助我构建一些表格。
所有数据库权限都存储在默认的 mysql 数据库中:information_schema. 只需创建一个有权查看此表中条目的 MySQL 用户,并在从 PHP 脚本连接时使用此用户的登录凭据。您可以从各种权限表(包括 DB 级、表级和列级权限)中检索权限以报告用户权限。就像是:
information_schema
SELECT * FROM`information_schema`.`user_privileges` WHERE`grantee` LIKE"'user'%";
运行此查询后,您可以在 PHP 中随意格式化结果。