[ECTO] How to create a SQL utf8mb4 database?

Hi,

I would like to create a database with a utf8mb4 encoding and I can’t find the options in the Ecto docs. Does anyone know how to make it possible?

my current configuration:

config :infrastructure_db, InfrastructureDb.Repo,
    adapter: Ecto.Adapters.MySQL,
    username: "root",
    password: "",
    database: "engine",
    hostname: "localhost",
    pool_size: 10
1 Like

The charset is configurable through Mariaex.start_link/1.

But to be honest I don’t know if you can add that attribute to the configuration you posted, or that it must be set elsewhere.

Edit: Also some information in the Ecto docs, seems like you can set the charset in your current configuration.

3 Likes

Thanks for pointing it out - i’m going to try

1 Like
config :infrastructure_db, InfrastructureDb.Repo,
    adapter: Ecto.Adapters.MySQL,
    username: "root",
    password: "",
    database: "engine",
    hostname: "localhost",
    pool_size: 10,
    charset: "utf8mb4"

this work !

2 Likes