1

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.

Mr. Radical
  • 1,847
  • 1
  • 19
  • 29
Mahbub
  • 21
  • 1
  • 4
  • Well I sorted out the problem, thanks to @Mr. Radical. The problem was caused by Cygwin, a Linux emulator in windows environment. Once I uninstalled the Cygwin the problem magically disappears. Now I reinstalled the MySQL using windows installer without any problem. – Mahbub Feb 10 '13 at 02:31

4 Answers4

2

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?

Community
  • 1
  • 1
Mr. Radical
  • 1,847
  • 1
  • 19
  • 29
  • Thanks @Mr. Radical. I have completely uninstalled mysql. So, logically when I type 'mysql' on the command line I should get: 'mysql' is not recognized as an internal or external command,...., instead I kept getting: Error 2002 (HY2000): Can't connect to local MySQL server through socket '/var/run/mysql.socket' (2). Any idea, how I can get rid of this problem? – Mahbub Feb 10 '13 at 01:25
  • You do now that you can use \mysql -u username -p (e.g. c:\xampp\mysql\bin\mysql.exe -u username -p) if you are outside of the directory. B.T.W. do you use an XAMPP type of system to setup your MySQL server. – Mr. Radical Feb 10 '13 at 01:34
  • @Mahbub have you tried the suggestions in the manual? http://dev.mysql.com/doc/refman/5.5/en//access-denied.html . Main point are to check if you firewall is not causing the problem. This probably not the case because you can access you db when you launch from the install directory. Another suggestion is to add the port (e.g. mysql -h hostname -P 3306 -u username -p). I used 3306 because it is the default port. – Mr. Radical Feb 10 '13 at 02:02
  • @Mahbub just to make sure does mysql start when you start it from the command line when you are in the installation directory. Because your error doesn't make sense MYSQL should have the same error if you run it from the installation directory. – Mr. Radical Feb 10 '13 at 02:12
  • Solved the problem. Cygwin caused this. Uninstalling Cygwin removed the problem. – Mahbub Feb 10 '13 at 02:16
  • Thanks @Mr. Radical for your suggestions. – Mahbub Feb 10 '13 at 02:17
  • See, this is what I thought. Your are not running your Mysql server on Windows. You are using an emulator. Therefore you got the linux style structure. If you are using windows why not use XAMPP and if you are using linux why not install lamp. – Mr. Radical Feb 10 '13 at 02:18
  • Oke, so your question is solved. Can you post your answer below and accept it. Maybe some else is interest in it in the future. And in the future you need to provide all stuff relevant to answer your question. – Mr. Radical Feb 10 '13 at 02:20
  • The problem was caused by Cygwin, a Linux emulator in windows environment. Once I uninstalled the Cygwin the problem magically disappears. – Mahbub Feb 10 '13 at 02:29
  • @Mahbub I am still a bit puzzeled was your mysql server installed on cygwin or wasn't it? – Mr. Radical Feb 10 '13 at 02:29
  • No, I installed mysql normally, but the cygwin somehow caused the problem. I uninstalled both mysql and cygwin, then reinstalled mysql with windows installer with no problem. – Mahbub Feb 10 '13 at 02:37
  • @Mahbub normally you accept an answer or up vote it if you think it has contribute to answering your question. In this case you have fixed it yourself, so you can add the answer below. And then accept it. I can do it for you but then I get the credit for something you have solved. – Mr. Radical Feb 10 '13 at 02:41
  • I don't know how to do it. I don't mind if you do it for me. Thanks. – Mahbub Feb 10 '13 at 02:44
  • @Mahbub on the bottom of this page you will find a button with "Post your answer". Click on it a type in your answer then submitted it. Next step is to accept the answer by placing a check mark in front of your answer. – Mr. Radical Feb 10 '13 at 02:47
  • @Mahbub I searched the SO database and google and found that most problems like this popup when users try to access an windows install of mysql via the cygwin command line (terminal). So, it you try that you might run in to the same problem. – Mr. Radical Feb 10 '13 at 03:00
0

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.

0

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

0

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)

Guillaume Polet
  • 47,259
  • 4
  • 83
  • 117