1

I don't know how to enable my MySQL client to accept letters with accents as input on the command line on Ubuntu. These chars are not echoed on the console nor accepted as input. As far as I remember, in previous versions of mysql, I solved this problem by launching the client with command mysql --default-character-set=utf8 but this doesn't work with mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using EditLine wrapper on Ubuntu 18.04.

What does work is echo 'SELECT "é" AS letter' | mysql <dbname>, which gives the correct output.

I suspect the EditLine wrapper to be guilty of this behaviour, but I don't know how to get rid of this unwanted feature.

Pierre François
  • 5,850
  • 1
  • 17
  • 38

3 Answers3

0

I discovered today that I inherited in my current bash an alias from the setup of a previous installation:

alias mysql='mysql --default-character-set=utf8'

Since I removed that alias (with unalias mysql), the misbehaviour disappeared.

Pierre François
  • 5,850
  • 1
  • 17
  • 38
-1

You can make your database support UTF-8 encoding

Try the following : ALTER DATABASE your_database_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Noblesse
  • 268
  • 2
  • 16
  • As far as I understand, the command you recommend affects the database and the server, but not the MySQL client. I issued it without any change at client side. – Pierre François Mar 01 '19 at 11:21
-1

If you are using Terminal,

Terminal > Preferences > Encodings > UTF-8 Unicode
Rick James
  • 135,179
  • 13
  • 127
  • 222
  • This is not the answer, since I am able to type "é" at the shell within the terminal. It is only inside mysql that the letters with accents don't show up. – Pierre François Nov 20 '19 at 10:04
  • Let's see `SELECT col, HEX(col) ...` for some row and column that is messed up. – Rick James Nov 20 '19 at 18:45
  • the columns (inside the database on the server side) are not messed up. The chars with accents never reach the server. The command line of the mysql client just ignores these when typed at the prompt. – Pierre François Nov 21 '19 at 08:55
  • 1
    @PierreFrançois - OK. That further implicates the terminal program. – Rick James Nov 22 '19 at 01:46