简体   繁体   English

在Amazon RDS的mysql / mariadb上创建用户时出现问题

[英]Issue creating users on mysql/mariadb on amazon RDS

Still trying to figure out RDS on AWS. 仍在尝试找出AWS上的RDS。 I setup an EC2 instance that I can SSH into. 我设置了可以通过SSH进入的EC2实例。 I then created an RDS instance of MariaDB. 然后,我创建了MariaDB的RDS实例。 I can SSH into my EC2 and then use MySQL to connect to the RDS instance using the username/password I created when I setup the RDS instance. 我可以通过SSH进入EC2,然后使用MySQL通过我在设置RDS实例时创建的用户名/密码连接到RDS实例。 When I look at the users I see 当我看着用户时,我看到

'myusername'@'%' 
'rdsadmin'@'localhost'

While logged in as 'myusername' to the mysql db, I create a new user with more limited hosts: 当以“ myusername”身份登录到mysql数据库时,我创建了一个具有更多受限主机的新用户:

CREATE USER 'otheruser'@'nnn.nnn.nnn.nnn' IDENTIFIED BY 'good_password'

No problems so far. 到目前为止没有问题。 Now give 'otheruser' some permissions: 现在授予“ otheruser”一些权限:

GRANT ALL PRIVILEGES ON mydatabase.* TO 'otheruser'@'nnn.nnn.nnn.nnn' IDENTIFIED BY 'same_password';

Seems to work. 似乎可以工作。 From my IP address I can use Navicat to connect as 'otheruser' to 'mydatabase' and can create tables, add data, drop tables, create indexes no problem. 通过我的IP地址,我可以使用Navicat作为“其他用户”连接到“ mydatabase”,并且可以创建表,添加数据,删除表,创建索引。 However, when I do this, all privileges show 'N': 但是,当我这样做时,所有特权都显示为“ N”:

SELECT * FROM mysql.user WHERE user = 'otheruser'\G

If I look in information_schema the only privilege is 'usage' 如果我查看information_schema,唯一的特权是“使用”

SELECT * FROM information_schema.user_privileges;

If, as my root user created during RDS setup I try to specify a specific privilege for 'otheruser' I get an access denied error. 如果作为我的RDS设置过程中创建的root用户,我尝试为“ otheruser”指定特定特权,则会收到拒绝访问错误。

So if all of the permissions are showing 'N', and information_scheme just shows 'usage', how is Navicat able to connect as that user and do pretty much everything? 因此,如果所有权限都显示为“ N”,而information_scheme仅显示为“使用情况”,那么Navicat如何能够以该用户身份连接并执行几乎所有操作?

What's the correct way of creating a restricted user on an RDS instance? 在RDS实例上创建受限用户的正确方法是什么? It seems the user created during instance creation is slightly limited vs. the 'rdsadmin'@'localhost', but AFAIK there's now way to connect to the RDS from localhost? 与“ rdsadmin” @“ localhost”相比,在实例创建过程中创建的用户似乎受到了一些限制,但是AFAIK现在有从本地主机连接到RDS的方法吗?

The privileges in the mysql.user table are global privileges. mysql.user表中的特权是全局特权。 They apply to all databases on the server, present and future. 它们适用于现在和将来服务器上的所有数据库。 You didn't issue a statement that would grant any of those. 您没有发布将授予其中任何一项的声明。

SELECT * FROM mysql.db; will show you where the navicat user's permissions you granted can be found. 将显示您在哪里可以找到您授予的navicat用户的权限。

You can GRANT ALL PRIVILEGES ON some_database.* in RDS, which grants only the database-level permissions for that one database. 您可以在RDS中的GRANT ALL PRIVILEGES ON some_database.*上授予GRANT ALL PRIVILEGES ON some_database.* ,这将仅授予该数据库一个数据库级别的权限。

...but you cannot GRANT ALL PRIVILEGES ON *.* because you, the master user, do not possess all global privileges. ...但是您不能授予GRANT ALL PRIVILEGES ON *.*因为您(主用户)并不拥有所有全局特权。 RDS doesn't give them to you. RDS不会将它们提供给您。 To do global grants, you have to grant specific privileges. 要进行全局授予,您必须授予特定的特权。

SHOW GRANTS FOR 'myusername@'%';

The privileges you see listed there are the only global (server-level) privileges you can grant. 您看到的特权列出了您可以授予的唯一全局(服务器级别)特权。

Yes, the things you can do with the privileges provided by RDS are limited, presumably because it's a managed service... so they don't want you to be able to break anything that they would have to fix for you... which they would, because it's a managed service. 是的,您可以使用RDS提供的特权来做的事情是有限的,大概是因为这是一项托管服务...所以他们不希望您能够破坏必须为您解决的任何问题...他们会的,因为这是一项托管服务。 That's one of the drawbacks of RDS. 这是RDS的缺点之一。 You trade some flexibility for ease of administration (point in time recovery, creation/monitoring/destruction of read replicas, backup snapshots, etc.). 您需要牺牲一些灵活性来简化管理(时间点恢复,只读副本的创建/监视/销毁,备份快照等)。

rdsadmin@localhost is the account the RDS infrastructure uses to manage and monitor your instance. rdsadmin@localhost是RDS基础结构用来管理和监视您的实例的帐户。 That's why it has all those privs. 这就是为什么它拥有所有这些特权。 You're correct -- you can't log in from localhost. 您是正确的-您无法从localhost登录。 Only the RDS supervisory process can. 只有RDS监督过程可以。

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

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