3

Using spring-boot-jpa auto generate create mysql's table, but the encoding is latin1.

How to change the encode to UTF-8.

The config is:

 spring.datasource.url=jdbc:mysql://localhost:3306/test
    spring.datasource.username=root
    spring.datasource.password=root
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
    spring.datasource.sql-script-encoding=UTF-8
Patrick
  • 12,336
  • 15
  • 73
  • 115
Beni
  • 51
  • 3
  • 1
    Try with `spring.datasource.sqlScriptEncoding=UTF-8` – Madhusudana Reddy Sunnapu Jan 21 '16 at 14:21
  • As far I understand you're looking to the wrong direction: if Hibernate creates tables, it doesn't specify their encoding. MySQL uses their default encoding in this case. So, if I would be you, I will try to configure MySQL server and set default encoding here. Maybe this question could help you in this: http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf-8-in-my-cnf – Slava Semushin Jan 21 '16 at 14:27
  • Do you talk about the encoding of the table column Character Set and Collation? – Ralph Jan 21 '16 at 16:18
  • show create table history; CREATE TABLE `history` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_symbol_date` (`symbol`,`date`) ) ENGINE=InnoDB AUTO_INCREMENT=1273 DEFAULT CHARSET=latin1 the encoding is latin1,I want to change to utf8 – Beni Jan 22 '16 at 02:18

1 Answers1

0

Just change the "default collation" in settings mysql server according Your demand, next drop and create schema (or table) again.

seq
  • 185
  • 2
  • 6