Cygwin connecting to MySQL: Can't connect to local MySQL server through socket '/var/run/mysql.sock'

cygwin, mysql

Solution

If you specify the host on the command line, this issue should go away:

mysql -u root -p -h 127.0.0.1

You can also create a `my.ini` that mysql will use:

echo [client] >c:\my.ini
echo user=root >>c:\my.ini
echo host=127.0.0.1 >>c:\my.ini

Then you can just type:

mysql -p

You can even add the password:

echo password="abracadabra" >>c:\my.ini

Then, just type:

mysql

and you're in!

See also https://serverfault.com/questions/337818/how-to-force-mysql-to-connect-by-tcp-instead-of-a-unix-socket

Problem

I just installed MySQL 5.5.27 on WinXP. When I open a command prompt (Start -> Run, and type "cmd"), I can access MySQL by running "mysql -u root -p". However, when I open a Cygwin terminal and try the same thing, I get this error ``` $ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2) ``` Indeed, there is no "/var/run/mysql.sock" file.

Original source

Related problems