简体   繁体   English

如何从RDS实例访问mysql日志

[英]How do I get access to the mysql logs from a RDS instance

如何从Amazon RDS实例访问MySQL日志(主要是为了查看插入/更新/删除语句)?

Basically you have to enable the "general_log" parameter in the parameter group of your RDS instance 基本上,您必须在RDS实例的参数组中启用“general_log”参数

$ rds-modify-db-parameter-group mydbparametergroup --parameters "name=general_log,value=ON,method=immediate" 

In case you did not apply the parametergroup to the instance: 如果您未将参数组应用于实例:

$ rds-modify-db-instance mydbinstance  --db-parameter-group-name mydbparametergroup

Then access your mysql instance using root: 然后使用root访问您的mysql实例:

mysql> select * from mysql.general_log;

See: 看到:

AWS Developer Forum - Re: general query log AWS开发者论坛 - Re:一般查询日志

AWS RDS - Working with DB Parameter Groups AWS RDS - 使用数据库参数组

EDIT: 4 years have past since I posted this answer, and it still seems valid. 编辑:自从我发布这个答案以来已经过去了4年,它似乎仍然有效。 I hope someone from Amazon RDS documentation team would read it and update their documentation. 我希望Amazon RDS文档团队的人员能够阅读并更新他们的文档。


I had a really hard time to figure such a simple thing out, because all online information in this regard seems outdated including one in Amazon Docs. 我很难想出这么简单的事情,因为这方面的所有在线信息似乎已经过时,包括亚马逊文档中的一个。 Amazon has obviously changed how you do things since now the default parameters cannot be modified, and you need to create a custom set of parameters in order to modify them, including general_log. 亚马逊显然改变了你的工作方式,因为现在无法修改默认参数,你需要创建一组自定义参数来修改它们,包括general_log。 It is an obvious bug that you can still click the Edit button for default parameters, but when you try to save them, you get an error that default parameters can't be changed. 这是一个明显的错误,您仍然可以单击“编辑”按钮以获取默认参数,但是当您尝试保存它们时,会出现无法更改默认参数的错误。

在此输入图像描述

How you do it now, is that in the Parameters Groups, click on Create DB Parameter Group, and create a new group and select the same DB in 'DB Parameter Group Family' as in the default parameter group. 现在,如何在参数组中单击创建数据库参数组,并创建一个新组,并在“数据库参数组系列”中选择与默认参数组中相同的数据库。 See the attached screen shot. 请参阅随附的屏幕截图。 Once done, it'll create a copy identical to the default parameter group. 完成后,它将创建与默认参数组相同的副本。 Now edit the parameters, eg change general_log to '1'. 现在编辑参数,例如将general_log更改为“1”。 According to the Docs is should be '0' by default but it is neither '0' nor '1' by default. 根据Docs默认情况下应为'0',但默认情况下它既不是'0'也不是'1'。

Now save it, go back to your instance, click on 'Instance Actions', select 'Modify' and in the setting which will appear, change 'Parameter Group' to your new custom parameter group. 现在保存它,返回到您的实例,单击“实例操作”,选择“修改”,然后在出现的设置中,将“参数组”更改为新的自定义参数组。 It'll take a few moments to apply it, after which you'll need to restart your DB instance. 它需要一些时间来应用它,之后您将需要重新启动数据库实例。

This is how it is till June 2014. But there is no guarantee that it'll stay like this in future too, since in the technology industry things keep getting updated too fast (many times unnecessarily) but documents and tutorials don't get updated as fast. 这就是2014年6月之前的情况。但是不能保证它在未来也会保持这样,因为在技术行业,事情变得太快(很多次不必要)但文档和教程没有得到更新一样快。

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

相关问题 如何从EC2实例对RDS实例进行MySQL查询? - How do I do MySQL queries on an RDS instance from an EC2 instance? 如何以编程方式连接到我的 RDS MySQL 实例? - How do I connect to my RDS MySQL instance programmatically? 如何从与我所在的 EC2 实例分开的 AWS RDS 实例的命令行运行 mysql 命令? - How do I run the mysql command from the command line of an AWS RDS instance that is separate from the EC2 instance I am on? 如何从实例下载Amazon RDS数据库? - How do I download an Amazon RDS database from an instance? 如何使用RDS mysql实例的IAM Auth在EC2实例上设置Grafana? - How do I setup Grafana on an EC2 instance using IAM Auth for an RDS mysql instance? AWS RDS:如何从本地主机访问/连接到RDS MySql DB - AWS RDS: How to access/connect to RDS MySql DB From localhost 如何将数据库从Amazon RDS MySQL实例导出到本地实例? - How to export database from Amazon RDS MySQL instance to local instance? 如何将Amazon Elastic Beanstalk MySQL RDS实例升级到5.6? - How do I upgrade my Amazon Elastic Beanstalk MySQL RDS instance to 5.6? 如何设置SSL以连接到RDS MySQL实例 - How do you setup SSL to connect to an RDS MySQL Instance root 用户无权访问 RDS MYSql 实例 - root user has no access to RDS MYSql instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM