Cafe24의 JAVA 호스팅 받는 경우이모지를 오류 없이 넣는 방법
[YOUR_CAFE24_ACCOUNT@umj64-007 ~]$ mysql -u YOUR_CAFE24_ACCOUNT -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 819210688
Server version: 5.5.17-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW VARIABLES LIKE 'character_set%';
+--------------------------+----------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------+
| character_set_client | binary |
| character_set_connection | binary |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | binary |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | binary |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
mysql> ALTER DATABASE YOUR_CAFE24_ACCOUNT
-> CHARACTER SET utf8mb4
-> COLLATE utf8mb4_unicode_ci;
Query OK, 1 row affected (0.00 sec)
mysql> use YOUR_CAFE24_DB_NAME
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select count(*) from bbs_board;
+----------+
| count(*) |
+----------+
| 1254 |
+----------+
1 row in set (0.00 sec)
mysql> ALTER TABLE bbs_board
-> CONVERT TO CHARACTER SET utf8mb4
-> COLLATE utf8mb4_unicode_ci;
Query OK, 1254 rows affected (0.14 sec)
Records: 1254 Duplicates: 0 Warnings: 0
mysql> ALTER TABLE bbs_board ROW_FORMAT=DYNAMIC;
Query OK, 1254 rows affected (0.04 sec)
Records: 1254 Duplicates: 0 Warnings: 0
mysql> SHOW VARIABLES LIKE 'character_set_database';
+------------------------+---------+
| Variable_name | Value |
+------------------------+---------+
| character_set_database | utf8mb4 |
+------------------------+---------+
1 row in set (0.00 sec)
5) JDBC 연결 설정도 확인
Spring Boot 또는 Spring JDBC 사용 시
url 에 반드시 useUnicode=true&characterEncoding=utf8mb4 포함.
application.properties / yml 예:
spring.datasource.url=jdbc:mysql://localhost:3306/yourdb?useUnicode=true&characterEncoding=utf8mb4&serverTimezone=Asia/Seoul
또는
spring: datasource: url: jdbc:mysql://localhost:3306/yourdb?useUnicode=true&characterEncoding=utf8mb4&serverTimezone=Asia/Seoul
|