如何使我的本地 mysql 设置与 Amazon RDS 匹配?
How can I make my local mysql settings match Amazon RDS?
我有一个设置,我使用本地 mysql 实例在本地进行开发,然后将我的代码推送到使用 RDS MySQL 实例的 AWS。
我想让我的本地数据库尽可能匹配 RDS 设置。我 运行 陷入配置问题,其中一个明显的问题不会在本地开发中表现出来,但我的测试在 RDS 上失败了。例如,最近的一个问题是 RDS 表的默认字符集是 latin1,而 brew-installed mysql 的默认设置是 UTF-8。
我可以在这些问题出现时解决它们,但是进行批量设置以配置我的本地 MySQL 以尽可能匹配 RDS 会非常有用。
这可行吗?
只需进入您在 RDS 中使用的参数组并将所有这些设置复制到本地 MySQL 服务器。
这是一个简短的 powershell 命令(基于建议的答案),用于检索指定参数组的所有非默认参数(将 "default.mysql-57" 替换为您正在使用的特定参数组名称):
Get-RDSDBParameter -DBParameterGroupName default.mysql5.7 |
select ParameterName, ParameterValue |
where {$_.ParameterValue -ne $null}
还有aws cli can be used to retrieve your RDS configuration. The command I used to pull it down is below. Replace YOUR_PARAMETER_GROUP_NAME
with your RDS parameter group name and the --source
can be system
, user
or engine-default
(or remove the --source
argument and it will retrieve them all). The below command uses jq。
aws rds describe-db-parameters --db-parameter-group-name YOUR_PARAMETER_GROUP_NAME --source system | jq -r '.Parameters[] | (.ParameterName + "=" + .ParameterValue)'
我有一个设置,我使用本地 mysql 实例在本地进行开发,然后将我的代码推送到使用 RDS MySQL 实例的 AWS。
我想让我的本地数据库尽可能匹配 RDS 设置。我 运行 陷入配置问题,其中一个明显的问题不会在本地开发中表现出来,但我的测试在 RDS 上失败了。例如,最近的一个问题是 RDS 表的默认字符集是 latin1,而 brew-installed mysql 的默认设置是 UTF-8。
我可以在这些问题出现时解决它们,但是进行批量设置以配置我的本地 MySQL 以尽可能匹配 RDS 会非常有用。
这可行吗?
只需进入您在 RDS 中使用的参数组并将所有这些设置复制到本地 MySQL 服务器。
这是一个简短的 powershell 命令(基于建议的答案),用于检索指定参数组的所有非默认参数(将 "default.mysql-57" 替换为您正在使用的特定参数组名称):
Get-RDSDBParameter -DBParameterGroupName default.mysql5.7 |
select ParameterName, ParameterValue |
where {$_.ParameterValue -ne $null}
还有aws cli can be used to retrieve your RDS configuration. The command I used to pull it down is below. Replace YOUR_PARAMETER_GROUP_NAME
with your RDS parameter group name and the --source
can be system
, user
or engine-default
(or remove the --source
argument and it will retrieve them all). The below command uses jq。
aws rds describe-db-parameters --db-parameter-group-name YOUR_PARAMETER_GROUP_NAME --source system | jq -r '.Parameters[] | (.ParameterName + "=" + .ParameterValue)'