connecting to mysql from cygwin

前端 未结 14 1674
时光说笑
时光说笑 2020-12-07 22:08

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         


        
相关标签:
14条回答
  • 2020-12-07 22:33

    Run bash from the cmd.exe executable and then mysql will work inside bash.

    1. Create a shortcut for cmd.exe on your desktop.
    2. Open up the properties for the shortcut and change the startup directory to the cygwin bin directory (usually C:\cygwin\bin).
    3. Add "/c bash.exe" to the end of the command in the target parameter.

    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.

    0 讨论(0)
  • 2020-12-07 22:39

    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.

    0 讨论(0)
  • 2020-12-07 22:42

    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.

    0 讨论(0)
  • 2020-12-07 22:43
    1. Download Cygwin
    2. Install mysql client app

    3. create an alias in .bashrc file

      alias mysql='mysql -h 127.0.0.1'

    4. execute source .bashrc

    Now you can connect to mysql

    mysql -u user -p

    0 讨论(0)
  • 2020-12-07 22:45

    Other answers lack the following key detail:

    Cygwin has two shells:

    1. Default: c:\cygwin\bin\mintty.exe
    2. Basic: 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)

    0 讨论(0)
  • 2020-12-07 22:45

    Do This:

    1. just copy ur mysql.exe from C:\Program Files\MySQL\MySQL Server 5.5\bin
    2. paste this mysql.exe in C:\cygwin\usr\local\bin
    3. now run which mysql, It will
    0 讨论(0)
提交回复
热议问题