I have a Spring web application talking to a mySQL database through hibernate. I am trying to set up utf8mb4 as the database character encoding. I have performed the following steps:
Setup my database using
SET NAMES utf8mb4; ALTER DATABASE mydb CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
Change hibernate url to
hibernate.connection.url = jdbc:mysql://localhost:myport/mydb?character_set_server=utf8mb4
- Add
SET NAMES 'utf8mb4'
to database connection initial SQLs on my Spring application configuration - Added
character_set_server=utf8mb4
at my.cnf
I managed to get my application working properly with a local database. Also what I found is that step 2 is not necessary and without step 4 my setup was not working locally.
In Openshift however I have not found a way to perform step 4. Is there any other solution to this problem? I have tried to change character_set_server
through phpMyAdmin variables but this is not working either.