Bug #66682 cmd.exe + chcp 65001 + mysqld.exe = bye form command-line and exit mysql
Submitted: 4 Sep 2012 12:58 Modified: 28 Jan 2013 13:09
Reporter: Angel Tsvetkov Email Updates:
Status: Won't fix Impact on me:
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.xx OS:Microsoft Windows (Windows 7 + XAMPP 1.8.0)
Assigned to: CPU Architecture:Any
Tags: way to resolve this problem
Triage: Needs Triage: D3 (Medium)

[4 Sep 2012 12:58] Angel Tsvetkov
Can't write in utf8 (65001 code page) via command prompt on Windows 7 and mysql 5.5.25a
>mysqld.exe + cmd.exe + type "chcp 65001" => bye form command-line and exit mysql

mysql> show variables like "char%"
| 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       | ...

How to repeat:
1) start mysqld
2) cmd.exe in windwos 7
3) chcp 65001
4) mysql -u root
5) try to type some symbols different from english alphabet
=> bye and mysql stops?!?!?!?!?!
Each alphabet "абсдеий.....юя" is interpterer like "exit" commant from mysqld
[4 Sep 2012 13:31] Godofredo Miguel Solorzano
Thank you for the bug report.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

h:\dbs>chcp 65001
Active code page: 65001

h:\dbs>5.5\bin\mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.29 Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

[4 Sep 2012 13:59] Angel Tsvetkov
Confirmed bug and for mysql 5.6.6-m9
[5 Sep 2012 5:26] Angel Tsvetkov
Confirmed bug and when using PowerShell or console under Windows 7
[5 Sep 2012 10:58] Angel Tsvetkov
Confirmed bug and when using OpenSSH for Windows 3.8.1p1-1 server and PuTTY 0.60 client. In this way i avoid to use cmd.exe of Windows 7, but problem persist
[5 Sep 2012 11:03] Angel Tsvetkov
Way to avoid this bug:
Use others mysql clients, especially with GUI, like SQLyog-10.3.0-0Community (tested and work ok) or HeidiSQL_7.0_Portable (tested and work ok), instead of original mysql command-line client (mysql.exe)
[7 Sep 2012 12:13] Vladislav Vaintroub
way to avoid : do not "chcp 65001".  It is the same old story "doctor, it hurts when I do this..." :)
[7 Sep 2012 13:28] Angel Tsvetkov
Vladislav, your way to avoid is the same as "do not use mysql". Please if you have constructive way to avoid this bug share it. Otherwise - shut up. This is place only for creative minds, not for trolls and diversion words ...
[19 Nov 2012 18:16] Sveta Smirnova
Could you please retest as described at http://dev.mysql.com/doc/refman/5.6/en/mysql-tips.html#windows-unicode-support:

1. Open a console window.

2. Go to the console window properties, select the font tab, and choose Lucida Console or some other compatible Unicode font. This is necessary because console windows start by default using a DOS raster font that is inadequate for Unicode.

3. Execute mysql.exe with the --default-character-set=utf8 (or utf8mb4) option. This option is necessary because utf16le is not supported as a connection character set. 

Please inform us about results.

Thanks in advance.
[21 Nov 2012 19:26] Leandro Morgado
I tested this on Windows 7 Home SP1. I first changed the shell font to Lucida Console as suggested.
The default font produced strange characters for UTF8.

What I find odd in the test below is that when invocking mysql with --default-character-set=utf8 the problem persists.
Without --default-character-set=utf8 they display correctly.

So using Lucida Console and not using --default-character-set=utf8 is a WORKAROUND for now.

See the following attached file (utf8test.txt) for the test results.
[21 Nov 2012 19:26] Leandro Morgado
UTF8 text file contain UTF8 tests on Windows 7 shell

Attachment: utf8test.txt (text/plain), 3.66 KiB.

[28 Jan 2013 13:09] Erlend Dahl
From the internal analysis:

This bug is due to the ANSI APIs being used to read the user data from console (ReadConsoleA). Fixing this bug needs conversion of the API from ReadConsoleA to ReadConsoleW. In addition to this conversion, we have to change internal buffers from 8 bit to wide char. This needs lot of changes and these changes are already implemented in 5.6 as part of work log 5331 (http://lists.mysql.com/commits/105379 ).

We tested 5.6 version of client against 5.5 version of server, especially with respect to non ANSI characters. The 5.6 client worked as expected and the issue mentioned in this bug was also fixed.

We are setting this bug to "won't fix" and we recommend to upgrade to 5.6 when that is available.