jeudi 25 juin 2015

How to set Amazon RDS SQL_MODE with multiple values

This is not really a question as I have already resolved my problem. I am just passing along what I found and what I did about it.

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.




Aucun commentaire:

Enregistrer un commentaire