i am trying to connect mysql DB with xampp in linux centos . but i am getting error like this .

Mysql Error : 2002- mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2).

i have stopped mysql server that was running separately in linux . so xampp is working properly mysql -->ok ,apache in xampp -->ok .

and i have checked phpmyadmin and previllages for root . you can check that

thanks for help.


Did you check your firewall? Refer to this link to enable connection to port 3306 if you are using iptables:


  • no , i did not checked firewall. – Waqas Rana Oct 17 '16 at 6:25
  • @WaqasRana try turning it off and check the connection to find out whether it is the cause. If so then add required firewall rules. – Bambang Oct 17 '16 at 6:42
  • ...check that , i am able to access phpmyadmin online . then how firewal issue? – Waqas Rana Oct 17 '16 at 6:50
  • i have added my ip in firewall , so i have to give my ip address instead of localhost in making connection to mysql. am i right? – Waqas Rana Oct 17 '16 at 6:54
  • @WaqasRana if your are connecting from localhost no need to put the ip address. Did you check this post: stackoverflow.com/questions/19658891/… – Bambang Oct 17 '16 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.