简体   繁体   English

新用户拥有MySQL 5.6的所有特权

[英]New user has all privileges in MySQL 5.6

I have a problem when I create a new user in mySQL 5.6 在mySQL 5.6中创建新用户时遇到问题

What I want: When I create the new user, it doesn't have any privileges, and I just want to grant some select and update in a few specific columns. 我想要的是:创建新用户时,它没有任何特权,我只想在一些特定的列中授予一些选择和更新。 So he should be able to update just anything at all the DB. 因此,他应该能够更新所有数据库中的所有内容。 Sounds fair. 听起来很公平。

So, first, I create a new user: 因此,首先,我创建一个新用户:

CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';

After this, I log in with my new user and when I do a show grants; 此后,我以新用户身份登录,并在获得show grants;时登录show grants; command I have this: 命令我有这个:

GRANT USAGE ON *.* TO 'newuser'@'%' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'

So in my theory he cant do anything in my database bacause he doesn't have any GRANT SELECT privilege. 因此,根据我的理论,他无法在数据库中执行任何操作,因为他没有任何GRANT SELECT特权。

But when I do a select in my test table he can view all columns and all results. 但是,当我在测试表中进行选择时,他可以查看所有列和所有结果。 He can update ... and do everything he wants to. 他可以更新...并做他想做的一切。 It's like he have a GRANT SELECT,UPDATE,DELETE ... ON *.* TO 'newuser'@'%' but I can't revoke that because he doesn't have that. 就像他具有GRANT SELECT,UPDATE,DELETE ... ON *.* TO 'newuser'@'%'但我无法撤消,因为他没有。

Of course, I've tried to revoke all privileges, but I can't because he doesn't have any privileges. 当然,我试图撤消所有特权,但是我不能,因为他没有任何特权。

I hope i'm clear. 我希望我很清楚。 So I'm confused, any ideas? 所以我很困惑,有什么想法吗?

Thanks! 谢谢!

Clément 克莱门特

In many default installations, all users have all privileges on tables within any database called test or beginning with test_ . 在许多默认安装中,所有用户都对名为test或以test_开头的任何数据库中的表具有所有特权。

From http://dev.mysql.com/doc/refman/5.6/en/default-privileges.html#idp5999952 : http://dev.mysql.com/doc/refman/5.6/en/default-privileges.html#idp5999952

By default, the mysql.db table contains rows that permit access by any user to the test database and other databases with names that start with test_. 默认情况下,mysql.db表包含允许任何用户访问测试数据库和其他名称以test_开头的其他数据库的行。 ...If you want to remove any-user access to test databases, do so as follows: ...如果要删除任何用户对测试数据库的访问权限,请执行以下操作:

mysql> DELETE FROM mysql.db WHERE Db LIKE 'test%';
mysql> FLUSH PRIVILEGES;

Alternatively, make sure that your test table isn't in a database with such a name, and then you'll see the true behaviour. 或者,确保您的测试表不在具有该名称的数据库中,然后您将看到真正的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM