I can successfully connect to MySQL from a DOS prompt, but when I try to connect from cygwin, it just hangs.
$/cygdrive/c/Program\\ Files/MySQL/MySQL\\ Serve
Run bash from the cmd.exe executable and then mysql will work inside bash.
This will run bash under the windows cmd.exe environment and when you attempt to run mysql it will execute as you would expect. This is working under windows 7 but has not been tested in any other version.
Althoug Svend Hansen answer has some points, another thing is the PATH in Environment variables - if the path to mysql is before that of cygwin
which mysql
will show
/cygdrive/c/Program Files/MySQL/MySQL Server 5.5/bin/mysql
otherwise it will show the cygwin client.
As reference Wikipedia says:
Some programs may add their directory to the front of the PATH variable's content during installation, to speed up the search process and/or override OS commands.
Disclaimer: The following solved this issue for me under MinTTY on MinGW/MSYS. From research, I believe this same root cause affects Cygwin as well.
Answer is posted here: https://stackoverflow.com/a/23164362/1034436
In a nutshell, you'll need to prepend your mysql
command with winpty's console.exe
(or have aliases that does so). This solution worked with native Windows MySQL executables and not a special cygwin/mingw build. You do, however, have to compile winpty, but that was simple and painless, and worked as per their documentation for me.
Note: This also solved my issue with several other native Windows console applications, namely Python and Mercurial with OpenSSH.
Install mysql client app
create an alias in .bashrc file
alias mysql='mysql -h 127.0.0.1'
Now you can connect to mysql
mysql -u user -p
Other answers lack the following key detail:
Cygwin has two shells:
c:\cygwin\bin\mintty.exe
c:\cygwin\Cygwin.bat
(which launches c:\cygwin\bin\bash.exe
)The Win32 MySQL can write properly to #2, but not #1, because Win32 MySQL cannot probe stdin properly (thanks @PeterNore)
Want to know if you're using Win32 MySQL? Use which
, e.g.
$ which mysql
/cygdrive/c/Program Files/MySQL/MySQL Server 5.1/bin/mysql
Bonus: Cygwin guide to overcoming path problems (thanks @Dustin)
Do This: