How to set only one table charset to utf8mb4 without change mysql configuration?

2.3k views Asked by At

Because of the emoji character, I need to change one of my tables to "utf8mb4" charset. After some google, all of the docs almost have the same steps:

1.Change mysql configuration in the config file, typically, /etc/my.cnf:

[mysql]
default-character-set=utf8mb4
......
[mysqld]
character_set_server=utf8mb4
......

Then restart mysql.

2.Change the database/table/column charset to utf8mb4, for example:

ALTER TABLE test_vstore_message_detail CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

or,

ALTER TABLE test_vstore_message_detail MODIFY `content` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE test_vstore_message_detail CHARSET=utf8mb4;

My question is, is it possible to ignore step 1, only apply step 2 to make the changes take effect? I only need to change the charset of one table, not of all the tables.

Currently the charset in mysql configuration is utf8, and we have no chance to restart the server in production. I have tried only step 2 but it didn't work.

0

There are 0 answers