Connecting to MySQL through Cygwin

cygwin, mysql

Solution

mysql -h 127.0.0.1 -P <PORT> -u root -p

This is what worked for me. Make sure you check what is the correct port.

Check the mysqld PID with:

ps -sW | grep mysqld

And then find the PORT with:

netstat -nao | grep <PID>

Have fun!

Problem

I have XAMPP running on my desktop and can connect to the MySQL server via phpMyAdmin. However, when I try to connect through Cygwin: Error: Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2) I've tried connecting to MySQL on the same machine, my local dev server and my remote server, all failed.

Original source