Search code examples
mysqlvariablesencodingconfigurationutf8mb4

How can I set mysql character_set_database as utf8mb4 without changing the config file?(since I have no access to the files)


I am using AWS Lightsail MySQL and I'm trying to set the encoding as utf8mb4. I was able to set some variables using the command

SET NAMES utf8mb4;
ALTER DATABASE etl_db CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

The result is

+--------------------------+--------------------+
| Variable_name            | Value              |
+--------------------------+--------------------+
| character_set_client     | utf8mb4            |
| character_set_connection | utf8mb4            |
| character_set_database   | latin1             |
| character_set_filesystem | binary             |
| character_set_results    | utf8mb4            |
| character_set_server     | latin1             |
| character_set_system     | utf8               |
| collation_connection     | utf8mb4_general_ci |
| collation_database       | latin1_swedish_ci  |
| collation_server         | latin1_swedish_ci  |
+--------------------------+--------------------+

But I cannot find a way to change character_set_database or the rest. The solutions online are all about changing the configure file. However, since I am using the AWS Lightsail MySQL service, I have no access to the files. Then how can I change the encoding of the rest variables?

btw, i wonder why can i change something within mysql while i can only change other things in my.cnf? Can I set buffer_size within mysql?


Solution

  • Lightsail Database parameters are configurable using aws-cli.

    https://lightsail.aws.amazon.com/ls/docs/en/articles/amazon-lightsail-updating-database-parameters

    You can change some values temporarily because the value of those variables are connection-specific SET NAMES only changes your current connection, not the default for all connections to the server itself.