Mahbub
Mahbub

Reputation: 31

MySQL error 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql.sock' in widows 7

Well, the question I am asking may seem stupid but it is biting me hard for the last couple of days. I am not able to run any mysql commands from the Windows command line even though the mysql installation folder is included in the PATH.

When I tried to execute a mysql command I got the above error. I tried several installation/un-installation of mysql version and ended up with no luck and got the same error. I kept getting that same error even after completely uninstalling mysql from Windows 7. If I open the cmd in the installation folder then there is no problem, but the problem arises when cmd is opened in other folder.

Upvotes: 1

Views: 8384

Answers (4)

Guillaume Polet
Guillaume Polet

Reputation: 47608

I solved this issue by modifying the order of the %CYGWIN_HOME%/bin and %MYSQL% path in the PATH environment variable. MYSQL binaries are now listed first in the PATH variable:

C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.7;c:\cygwin\bin;...

Of course it requires to start a new command prompt in order to work (environment variables are cached upon laucnhing of the command prompt)

Upvotes: 0

user2461292
user2461292

Reputation: 1

Just uninstall all mysql client libraries using setupXXX.exe (filtered for mysql) solved this problem for me.

Upvotes: 0

Peter Nicholson
Peter Nicholson

Reputation: 1

I had this issue after changing the mysql ini file C:\wamp\bin\mysql\mysql5.5.24\my.ini I thought that because MySQL 5.5 uses InnoDB then I should change by uncommenting the last section in this, but even though I changed the paths it caused the error 2002. When I re-commented it ie restored the original settings then everything worked OK.

Upvotes: 0

Mr. Radical
Mr. Radical

Reputation: 1855

EDIT

OP has solved this question himself by removing an existing cygwin install and mysql install and then subsequently reinstalling the mysql and cygwin again.

I tried it out myself and ran into the same problem at first. However, this how I solved it. I added c:\xampp\mysql\bin to the path system environment variables. I use XAMPP but your can change it to your installation directory. Note that that I didn't set the path in the user variables. If you add the path to the user variables it doesn't work, however when you add the path to system it does. Make sure your MYSQL server is running otherwise that you will get a message that your can not connect. Hope this helps.

For reference see: How can I access the MySQL command line with XAMPP for Windows?

Upvotes: 2

Related Questions