So my question is duplicate or mundane but i really can use some help here. I want to store emojis and some special characters in specific columns of 3 tables. My application is a workflow engine Processmaker running inside docker. This application talks with mysql server running as another docker container.
To solve the issue i have followed below links and did the changes too but all in vain. The databases are created dynamically.
- How to store Emoji Character in MySQL Database
- https://dba.stackexchange.com/questions/153720/mysql-unable-to-store-emoji-in-utf8mb4-collation
Please correct me if i am wrong. Even if i want to save emoji into 3 tables i have to change the collation and charset of :
- The Database.
- Associated tables in which i want to store emojis.
- Associated columns of those tables which would hold those emoji characters.
I achieve above steps (1-3) by running mysql queries after database creation, like so :
ALTER DATABASE database CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
ALTER TABLE table_one CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE table_one CHANGE column_one column_one mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE table_two CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE table_two CHANGE column_two column_two mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
SET NAMES utf8mb4;
for changing the collation and charset i also tried the approach of configuring it in my.cnf as such ( to achieve step 1 - step 2 ) :
[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
character-set-client-handshake = FALSE
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
All of above steps doesn't seem to work. Also the mysql server can have lot of databases which are created dynamically. Right after the database creation i run below query :
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
My sql client also uses utf8mb4 charset and collation as utf8mb4_unicode_ci. Since there could be hundreds of databases and it isn't possible for me to go and run these queries manually for each of them
So i was thinking if i can run some queries right after database creation OR Is there a way to do it ?
Mysql server version - 5.6.48 running in docker. If you need further info kindly let me know.
Any help would be much appreciated.
Thanks in advance.