I have just switched from MySQL to MariaDB and am running into a very silly problem: I cannot enter any extended characters in the database (for example, ö ä or å).
The system is utf8, and I tried switching the keyboard to swedish — works everywhere except for mariadb prompt, and even tried copying and pasting from gucharmap — nothing is pasted at prompt.
Either method worked under MySQL in the past. I looked in MariaDB conf.d
, the character_set_system
was not set so I changed it to utf8, but that did not help. default-character-set
in 50-client.cnf
is set to utf8mb4. Any ideas?
System: debian bulseye/sid
Mariadb: Ver 15.1 Distrib 10.5.8-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
These are the relevant mariadb variables:
| 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/ |
| collation_connection | utf8mb4_general_ci |
| collation_database | utf8mb4_general_ci |
| collation_server | utf8mb4_general_ci |
| session_track_system_variables |
autocommit,character_set_client,character_set_connection,character_set_results,time_zone
show create table gives
ENGINE=InnoDB AUTO_INCREMENT=1625 DEFAULT CHARSET=utf8mb4
The rest are field definitions, and no collations are set.
Of course, there is a prompt: it is a standard mysql prompt.
I am not sure how to make it clearer. I am at mysql prompt. In the past, typing something like å worked fine, now it shows nothing. When I try to paste the character copied from another utility like gucharmap, nothing is pasted. When I paste "normal" characters (i.e. standard English text) everything works.
Note that the extended characters in database entries created BEFORE the switch show up just fine. Yes, it is all very mysterious.
Best Answer
If you are using Windows
cmd
, you needchcp 65001
before entering mysql/mariadb. Since you are using a Linux variant,terminal
may needSET NAMES utf8mb4;
from within the mysql/mariadb.If the columns are not utf8mb4, you will have other problems. Check a table by using
SHOW CREATE TABLE tablename;
This provides a rundown on common problems and leads to their solutions: https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored