Search code examples
slick

How to setting charset to utf8 when create schema in scala slick 3.2?


I'm use db.run(DBIOAction.seq(chartRef.schema.create)) to create a table for mysql.But it charset show as latin1.How to make the table's charset as utf8 when create schema?

I have append useUnicode=true&characterEncoding=UTF-8 to connection url string.


Solution

  • There are two ways:

    1. Either set it manually by setting the db collation to UTF-8
    2. Try this

      db.default.url="jdbc:mysql://localhost/db_name?characterEncoding=UTF-8"

    Configure URL using this link.

    Please let me know if it works.