I have a problem saving unicode characters in MySql.
Initially my database character set was set to latin1 and unicode strings were  saves as quotation marks. After doing some research I added the following lines to my.cnf:
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
and executed the query:
ALTER DATABASE <my_database> CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
After restarting mysql, I get an error:
"org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Could not execute JDBC batch update; uncategorized SQLException for SQL ... Incorrect string value: '\xD0\xBA\xD1\x81\xD0\xB5...' for column 'first_name' at row 1"
Query mysql> show variables like 'char%'; returns the result:
Variable_name              | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/
and query mysql> show create database <my_database> gives:
| Database  | Create Database                                                       |
+-----------+-----------------------------------------------------------------------+
| my_database | CREATE DATABASE `my_database` /*!40100 DEFAULT CHARACTER SET utf8mb4 */
I know this question was answered many time but I tried everything I found in google and still couldn't fix it. Any help is appreciated!
UPDATE
After querying SHOW CREATE TABLE, I saw that DEFAULT CHARSET of the table was latin1.
I altered table with ALTER TABLE my_table CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
After that each column had CHARACTER SET set to latin1, while DEFAULT CHARSET at the end of the query result was utf8mb4
After altering the column with ALTER TABLE my_table MODIFY my_column VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, I got rid of the error when saving the value, but it went back to saving the string with question marks. Still haven't found the problem
 
     
     
     
    