Can not insert accents in MySQL REPL I have been trying to run a MySQL database in a Docker container using the official image. I can run everything OK but I have a problem with inserting accents.

The thing is that I can not insert accents on the MySQL REPL (or CLI or shell or... I am not sure how to call it; I mean where you see the mysql&gt; prompt). Nonetheless I can exit to the main Linux shell (prompt #) and insert accents normally.

I know that UTF8 is not reliable in MySQL so I tried to set utf8mb4. The character settings I do is:

mysql&gt; set names utf8mb4;
mysql&gt; set character_set_database=utf8mb4;
mysql&gt; set character_set_server=utf8mb4;
mysql&gt; set character_set_system=utf8mb4;


You can see what I have:

mysql&gt; show variables like "%character%";
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)


Thanks.
I finally found a solution. The problem might be that I was setting utf8mb4 just for a database, not for the mysqld daemon.

Anyway I put here what I made. I first created a Dockerfile:

FROM mysql:latest

RUN apt-get update &amp;&amp; apt-get install -y locales &amp;&amp; rm -rf /var/lib/apt/lists/* \
  &amp;&amp; localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8

COPY conf.d/ /etc/mysql/conf.d/

ENV MYSQL_ROOT_PASSWORD pass
ENV MYSQL_DATABASE gastos


As you can see, I copy a conf.d directory I just made. Inside this directory there is a character_set.cnf file:

[mysqld]
character_set_server = utf8mb4
collation_server = utf8mb4_general_ci