MySQL allows parameter SQL_MODE to be set to multiple values in the my.cnf file. How can I do the same on Amazon RDS?
UPDATE: This problem has been fixed...see below.
To modify an RDS DB instance configuration, follow these steps: Create a DB parameter group. View the parameter values for a DB parameter group to confirm that the Is Modifiable property is true. Modify the parameters in a DB parameter group.
It is the basic building block of Amazon RDS. A DB instance can contain multiple user-created databases, and can be accessed using the same client tools and applications you might use to access a standalone database instance.
Each default parameter group contains database engine defaults and Amazon RDS system defaults based on the engine, compute class, and allocated storage of the instance. You can't modify the parameter settings of a default parameter group.
You can increase the maximum number of connections to your RDS for MySQL or RDS for PostgresSQL DB instance using the following methods: Set a larger value for the max_connections parameter using a custom instance-level parameter group. Increasing the max_connections parameter doesn't cause any outage.
MySQL allows parameter SQL_MODE to be set to multiple values in the my.cnf file. However, Amazon RDS allows only one value, whether you use their browser-based console or their CLI tools.
I have found a (perhaps not perfect) solution to the problem of not being able to set SQL_MODE to multiple values. In my procedure below, I show what my settings are. You may choose whatever values you think are pertinent to your environment.
1) In your parm group, set SQL_MODE = TRADITIONAL (or which ever one value is your highest priority)
2) In your parm group, set init_connect to: SET SESSION sql_mode = 'TRADITIONAL,IGNORE_SPACE,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY'
Now when a client logs into the database, their session SQL_MODE should be set to all values passed in by the init_connect string. In my case, this equates to: IGNORE_SPACE, ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, TRADITIONAL, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION
Caveat: Editing the init_connect value after setting it involved cut-n-paste. However, I found that trying to delete an init_connect value after setting it is a big hassle, so be careful in working with it. The hassle? To delete an init_connect value after setting it required that I create a new parm group from scratch, set all values except init_connect to what the original parm group had, delete the original parm group, then rename the new group with the old name. This was true with both Firefox and Chrome. I also could not delete the value using the CLI tool (aws rds modify-db-parameter-group).
Although not really part of this post, if anyone responds with how to delete/reset/null-out init_connect without the kind of hassle I describe above, that would be great.
UPDATE 1:
Never mind. I have discovered that an init_connect setting (on RDS) will NOT survive a database reboot. Therefore, the solution I offered above does not work.
Also, since one cannot remove (delete) an init_connect setting through the console (why not?), one can remove it by using the aws rds reset-db-parameter-group CLI command rather than rebuilding the whole parameter group like I described before.
I am VERY disappointed that Amazon RDS:
UPDATE 2:
Per Ross Scrivener's response, I tested setting multiple SQL_MODE values through the AWS console. I used the values 'TRADITIONAL,IGNORE_SPACE,ONLY_FULL_GROUP_BY' (no spaces). I then rebooted the server twice, and everything seemed to have held.
Thank you Amazon for fixing this, and thank you Ross Scrivener for pointing out the AWS change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With