Bug #3601 mysql client hangs in ssh session in cygwin
Submitted: 29 Apr 2004 17:44 Modified: 30 Apr 2004 4:38
Reporter: Ross Smith Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.0.18 OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[29 Apr 2004 17:44] Ross Smith
Description:
Install Cygwin 1.5.9 (latest) and MySQL 4.0.18 in Windows.

Select Start/Programs/Cygwin/Cygwin Bash Shell

Type:

$ mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11 to server version: 4.0.18-max-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> exit

$ ssh localhost

$ mysql

(system hangs until you press Ctrl-C)

How to repeat:
See above

Suggested fix:
Unknown at this time.
[30 Apr 2004 4:38] MySQL Verification Team
miguel@light ~
$ cd 4.0.18/bin/

miguel@light ~/4.0.18/bin
$ ./mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 4.0.18-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> exit
Bye

miguel@light ~/4.0.18/bin
$ ls mysql.exe -la
-rwxrwxrwx    1 miguel   Nenhum     294980 Feb 11 01:57 mysql.exe

miguel@light ~/4.0.18/bin
$
[20 Oct 2006 14:55] Cecil J
I'm experiencing this exact same issue, using Cygwin 1.5.21-1 (latest as of Oct 2006) and MySQL 5.0.26 on Windows 2000 SP4.  I'm using the precompiled OpenSSH 4.4p1 with OpenSSL 0.9.8d included with this Cygwin release.

The MySQL command line client works fine from a cygwin bash window, but hangs with no output when run while connected via ssh.  Note that the program does execute successfully when simply asked to return the version number or help (--version or --help flags).  I have also attempted manually specifying the host and port, specifying --protocol=tcp, etc, to no avail.

Output from a Cygwin bash console:

[~][root@nanao] mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.26-community-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit
Bye
[~][root@nanao] ssh localhost
Last login: Fri Oct 20 10:49:50 2006 from 127.0.0.1
Welcome to nanao.
[~][root@nanao] mysql

*** program hangs, CTRL-C pressed ***

[~][root@nanao] mysql --version
c:\Program Files\MySQL\MySQL Server 5.0\bin\mysql.exe  Ver 14.12 Distrib 5.0.26,
 for Win32 (ia32)
[~][root@nanao] exit
logout
Connection to localhost closed.
[~][root@nanao] mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.26-community-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit
Bye
[~][root@nanao]
[1 Nov 2006 9:29] teej TJ
I've recently experienced the very same problem connecting via ssh to Cygwin/sshd on Windows 2003 Server.

From my research it *appears* the issue is to do with the way cygwin uses pty masquerading as tty.

Apparently the issue is that cygwin/sshd uses a file/pipe to simulate tty to mysql utilities (mysql, mysqladmin, etc.) and those apps treat it as a pipe, not stdin, and therefore don't provide interactivity.

This may be wrong - the sources were minimal but hopefully it'll help others to avoid the frustrations.
[28 Jan 2007 20:56] Felix Zaslavskiy
I had this problem too. I am using a version of mysql compiled as native windows binary. In cygwin when I start the mysql client from bash the program simply hangs. Although I can star the mysqld just fine. The mysql client works fine from the windows cmd.exe. Seems like a problem with cygwin.
[3 Dec 2007 8:53] Kai Seidler
The mysql.exe command is actually working but the IO isn't working. You can check this by typing "blindly" commands, like "quit", which will end the client. It's a known problem with some Windows executables in Cygwin.

One good workaround is to compile you own MySQL client in Cygwin (./configure --without-server) and use the resulting native Cygwin binary. Use -h127.0.0.1 to connect to Windows's MySQL service, because -hlocalhost refers to UNIX domain socket communication via /tmp/mysql.sock.