如何从 RDS 实例访问 mysql 日志
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8722565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I get access to the mysql logs from a RDS instance
提问by priya
How do I get access to the MySQL logs (primarily to take a look at the insert/update/delete statements) from an Amazon RDS instance?
如何从 Amazon RDS 实例访问 MySQL 日志(主要是查看插入/更新/删除语句)?
回答by user1045217
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
回答by zeeshan
EDIT: 4 years have past since I posted this answer, and it still seems valid. I hope someone from Amazon RDS documentation team would read it and update their documentation.
编辑:自从我发布这个答案以来已经过去了 4 年,它似乎仍然有效。我希望 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. 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.
我真的很难弄清楚这么简单的事情,因为这方面的所有在线信息似乎都过时了,包括 Amazon Docs 中的信息。亚马逊显然已经改变了你做事的方式,因为现在默认参数无法修改,你需要创建一组自定义参数才能修改它们,包括general_log。一个明显的错误是您仍然可以单击默认参数的编辑按钮,但是当您尝试保存它们时,您会收到无法更改默认参数的错误。
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, e.g. change general_log to '1'. According to the Docs is should be '0' by default but it is neither '0' nor '1' by default.
您现在的做法是,在参数组中,单击创建数据库参数组,然后创建一个新组并在“数据库参数组系列”中选择与默认参数组相同的数据库。请参阅随附的屏幕截图。完成后,它将创建一个与默认参数组相同的副本。现在编辑参数,例如将general_log 更改为'1'。根据文档,默认情况下应为“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 月都是这样。但不能保证将来也会保持这样,因为在技术行业中,更新速度太快(很多时候是不必要的),但文档和教程没有更新一样快。