我对 MySQL 还很陌生,我一直在创建测试表等。
无论如何,我创建了一个新用户,使用
创建由“myPassword”标识的用户“myUser”@“localhost”;
现在,当我登录到该用户时,我可以从之前使用 root 创建的表中SELECT
。这当然不可能吗?用户没有 SELECT
权限,甚至没有任何权限。如果(以 root 身份登录)我执行以下任一操作:
显示“myUser”@“localhost”的补助金;
或者
从 information_schema.user_privileges 中选择*,其中受让人喜欢“'myUser'@%”;
我可以看到他们只有 USAGE 权限。我的理解是设置此权限表示用户没有权限。
那么该用户如何从我的表中进行选择呢?
如果我这样做:
从 information_schema.table_privileges 中选择*;
没有返回结果。
我在这里缺少什么? SELECT
之类的某些功能是否隐式授予新用户?我必须明确撤销此操作吗?
如果是这样,还隐式授予了哪些其他权限?
理想情况下,我的目标是用户除了运行我用 GRANT EXECUTE ON
指定的一个(或多个)存储过程之外什么都不做。
最佳答案
我从来没有想过您会在测试模式中创建生产表 - 但事实证明这记录在 MySQL refman 中(强调):
In addition, the
mysql.db
table contains rows that permit all accounts to access thetest
database and other databases with names that start withtest_
. This is true even for accounts that otherwise have no special privileges such as the default anonymous accounts. This is convenient for testing but inadvisable on production servers. Administrators who want database access restricted only to accounts that have permissions granted explicitly for that purpose should remove thesemysql.db
table rows.
因此,这解释了您的发现:“无论哪种方式,即使删除它然后重新创建它,如果它的名称为“test”,匿名用户等都将始终可以访问它。”
关于mysql - 没有权限的用户仍然可以选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17897031/