We are using Google Cloud Sql Second Generation with our AppEngine application. However today we've discovered some problem, we cannot insert emoji characters to our database because we cannot change some server flags to utf8mb4 character encoding.
We've changed character_set_server flag to utf8mb4 but it wasnt enough
We have to change: character_set_system character_set_client collaction_connection
flags to utf8mb4 also, but second generation db is not allowing root user to change those flags. What can we do to solve this problem
Does anyone have any idea about that?
Thanks
You have to set character_set_server
to utf8mb4
, change the columns you need to utf8mb4
and create a new Cloud SQL 2nd gen instance with the new flag (!!). Basically, setting the flag on an existing instance and just restarting (tested with 5.7) will not be enough (is this a bug? I did not find it in the docs). Any encoding related connection parameters are not needed and should be removed. The collation will be the standard collation for utf8mb4
which is perfect for me (and probably most cases), even without setting anything.
We had the exact same problem. Setting character_set_server
to utf8mb4
wasn't enough. We could insert emojis through MySQL Workbench, but not through our application.
In our case, this problem went away after we started a new instance running MySQL 5.7 instead of 5.6. So my hypothesis is that in 5.7, but not in 5.6, changing the character_set_server
flag lets Google Cloud SQL change those other flags you mention, or some other relevant setting.
Of course if you are already running 5.7, this does not apply to you.
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