Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to MySQL through Cygwin

Tags:

mysql

cygwin

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.

like image 446
Nathan Avatar asked Jun 12 '12 11:06

Nathan


People also ask

How do I connect to MySQL database in Windows?

Enter mysql.exe -uroot -p , and MySQL will launch using the root user. MySQL will prompt you for your password. Enter the password from the user account you specified with the –u tag, and you'll connect to the MySQL server.

How do I connect to a MySQL server?

You can connect to a MySQL Server using the Database > Connect to Database… menu or click the + button that locates next to the MySQL Connections. Just click the + button in next to the MySQL Connections to continue.

Is MySQL on Cygwin a good server material?

And that’s it. MySQL on Cygwin is hardly server material, but it is good for practicing if you don’t want to set up a VM for the purpose.

What is the difference between MySQL and MariaDB on Cygwin?

MySQL is a well known database, which you will need if you plan on setting up a locally hosted site for web development, or similar. MariaDB, a fork of the project which came into existence after Oracle purchased MySQL, is not yet available on Cygwin as of 2015 or on Cygwin Ports, but watch this space.

How do I connect to a MySQL database in Workbench?

Connect to MySQL Using MySQL Workbench. Step 1. Launch the MySQL Workbench. You can connect to a MySQL Server using the Database > Connect to Database… menu or click the + button that locates next to the MySQL Connections. Just click the + button in next to the MySQL Connections to continue. Step 2.


1 Answers

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!

like image 117
Moreno Garcia Avatar answered Sep 30 '22 07:09

Moreno Garcia