The solution is to set the connection variables to any code page that your installation for Windows uses (and not latin1, like what many pages recommend). The character encoding of cmd.exe is not latin1).
In my case, code page 850:
mysql> SET NAMES cp850;
Here is an example connection with UTF-8:
mysql> show variables like '%char%'; +--------------------------+---------------------------------+ | Variable_name | Value | +--------------------------+---------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | C:\xampp\mysql\share\charsets\ | +--------------------------+---------------------------------+ 8 rows in set (0.00 sec)
Here's what happens with accented characters:
mysql> select nom from assignatura where nom like '%prob%'; +---------------------------------------+ | nom | +---------------------------------------+ | Probabilitat i Processos Estocàstics | | Probabilitat i Processos Estocàstics | +---------------------------------------+ 2 rows in set (0.03 sec)
Pay attention to the extraneous symbol ├ before á . Also the emphasis is the wrong direction, it should be à .
After executing SET NAMES cp850; :
mysql> show variables like '%char%'; +--------------------------+--------------------------------+ | Variable_name | Value | +--------------------------+--------------------------------+ | character_set_client | cp850 | | character_set_connection | cp850 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | cp850 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | C:\xampp\mysql\share\charsets\ | +--------------------------+--------------------------------+ 8 rows in set (0.00 sec)
Finally, we get the correct accented character:
mysql> select nom from assignatura where nom like '%prob%'; +--------------------------------------+ | nom | +--------------------------------------+ | Probabilitat i Processos Estocàstics | | Probabilitat i Processos Estocàstics | +--------------------------------------+ 2 rows in set (0.00 sec)
source share