简体   繁体   English

在Amazon RDS环境中创建新的MySQL用户

[英]Creating A New MySQL User In Amazon RDS Environment

I need to create a new MySQL user with limited permission on an existing Amazon RDS instance. 我需要在现有的Amazon RDS实例上创建一个具有有限权限的新MySQL用户。 After encountering a couple error messages I was sort of able to do this using the official MySQL Administrator tool and the user now appears in the list. 在遇到一些错误消息后,我有点能够使用官方MySQL管理员工具执行此操作,用户现在出现在列表中。 However, I'm unable to assign any schema privileges as all the users are greyed out. 但是,我无法分配任何架构权限,因为所有用户都显示为灰色。 I'm logged in as the "master user" created when the instance was launched. 我以实例启动时创建的“主用户”身份登录。 Not sure where to go from here. 不知道从哪里开始。 I do have the RDS command line tools installed but wasn't able to track down anything there either. 我确实安装了RDS命令行工具,但无法跟踪任何内容。 Ideas 思路

Your best bet is probably to connect to the database with a mysql command line client and call the SQL commands to create a new user and assign him privileges. 您最好的选择可能是使用mysql命令行客户端连接到数据库,并调用SQL命令来创建新用户并为其分配权限。

For instance, you might run something like this: 例如,您可能会运行以下内容:

mysql -u [your_master_username] -p -h YOURRDSENDPOINT.rds.amazonaws.com

CREATE USER 'jeffrey'@'%' IDENTIFIED BY 'somepassword';
GRANT SELECT ON [your_database].[some_table] TO 'jeffrey'@'%';

On windows you could use the mysql.exe client, wherever that is. 在Windows上,你可以使用mysql.exe客户端,无论在哪里。

Useful Docs 有用的文档

AWS RDS security groups documentation (a common area of confusion): http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithSecurityGroups.html AWS RDS安全组文档(常见的混淆区域): http//docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithSecurityGroups.html

User creation documentation: http://dev.mysql.com/doc/refman/5.5/en/create-user.html 用户创建文档: http//dev.mysql.com/doc/refman/5.5/en/create-user.html

Privilege granting documentation: http://dev.mysql.com/doc/refman/5.5/en/grant.html 权限授予文档: http//dev.mysql.com/doc/refman/5.5/en/grant.html

I know this thread is a couple of years old and well I keep finding it so I wanted to get an update out about the AWS RDS and User Permissions. 我知道这个帖子已经有几年了,而且我一直在寻找它,所以我想获得有关AWS RDS和用户权限的更新。

You cannot use GRANT ALL for any user with an RDS. 对于具有RDS的任何用户,您不能使用GRANT ALL When you use the GRANT ALL statement you are also attempting to provide Global (as AWS Calls them Super Permissions ) and with the way that the AWS RDS System is setup they do not allow assigning of Global Options to users. 当您使用GRANT ALL语句时,您还尝试提供Global (作为AWS调用它们Super Permissions ),并且通过AWS RDS系统的设置方式,它们不允许为用户分配全局选项。

You have to break out the Permissions to the following: 您必须将权限分解为以下内容:

GRANT SELECT,INSERT,UPDATE,DELETE,DROP on

This will allow your user to be able to connect to the RDS once the security settings are setup to allow access from your EC2 Instances or from the Internet. 这将允许您的用户在设置安全设置后能够连接到RDS,以允许从EC2实例或Internet访问。

Hope this information helps anyone else that is running into the same issues that I was seeing with the AWS RDS Systems. 希望这些信息可以帮助遇到与我在AWS RDS系统中遇到的相同问题的其他任何人。

Waldo 沃尔多

I created like this: 我这样创建:

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'somepassword';
GRANT SELECT ON mydatabase.* TO 'jeffrey'@'localhost';

But then, AWS rejected to login to that user. 但随后,AWS拒绝登录该用户。 And I tried to change Admin privileges, but not success. 我试图改变管理员权限,但没有成功。 And I change 'localhost' to '%' through mysql workbench. 我通过mysql workbench 将'localhost'更改为'%' (or you can remove the user and recreate) like : (或者您可以删除用户并重新创建),例如:

CREATE USER 'jeffrey'@'%' IDENTIFIED BY 'somepassword';
GRANT SELECT ON mydatabase.* TO 'jeffrey'@'%';

Then only I was able to loggin through this new user. 然后只有我能够通过这个新用户登录。

In addition: Once you done this change, then your database allowed to connect from any ip. 另外:完成此更改后,您的数据库就可以从任何IP连接。 If you need to improve the security and restrict the accessing ip (Ex: if this is a staging database), you can set the bind-address in my.cnf file in your server. 如果需要提高安全性并限制访问ip(例如:如果这是一个临时数据库),可以在服务器的my.cnf文件中设置bind-address。

bind-address = your.ip.add.ress bind-address = your.ip.add.ress

enter link description here 在此输入链接描述

I had the most success using MySQL Workbench and executing raw SQL against RDS: 我使用MySQL Workbench并对RDS执行原始SQL最成功:

CREATE USER 'foo'@'localhost' IDENTIFIED BY 'password';

The bigger problem was permissions. 更大的问题是权限。 Initially I tried: 最初我尝试过:

Grant ALL on *.* to 'foo'@'localhost'

... which results in an Access Denied error. ...导致访问被拒绝错误。

Error Code: 1045. Access denied for user 'foo'@'%' (using password: YES)

The troublesome permission is "super" which RDS doesn't give me, and in turn I can't grant. 麻烦的许可是RDS没有给我的“超级”,反过来我不能授予。 As a result, I'm stuck doing permissions by hand: 结果,我卡住了手工权限:

Grant SELECT on *.* to 'foo'@'localhost';
Grant INSERT on *.* to 'foo'@'localhost';
Grant CREATE on *.* to 'foo'@'localhost';

I have used mySQL workbench and it works fine. 我使用了mySQL工作台,它工作正常。 just go to management/Users and Privileges, press "Add Account" button bottom left, and configure. 只需转到管理/用户和权限,按左下角的“添加帐户”按钮,然后进行配置。 You cannot give SUPER privileges, but most of the rest 你不能给予SUPER特权,但其余大多数都是

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

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