Having to set up a server from scratch and install PHP & MySQL, running into an issue getting PHP to connect to MySQL. I can successfully connect to the database via command line, but when I try to do it through PHP I get this error:

#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured) 

The mysql server is running and can be connected to via command line. The .sock file is in the correct path and is chmod 777 so it can be connected to by any user.

Running PHP Version 5.2.14. MySQL Client API version 5.0.90, MySQL version 5.1.50

Using phpMyAdmin to connect, and have tried tcp and socket type connections. All give the same error.

  • What distribution? do you have the php-mysql package installed for it? Sep 20 '10 at 14:12
  • Yes I do, php-mysql-5.2.14-2.el5.art
    – Louis W
    Sep 20 '10 at 15:00
  • Wow. Ok so I found it. Talk about strange problem. Saw in the system logs "SELinux is preventing the http daemon from connecting to network port 3306 For complete SELinux messages." so I disabled SeLinux (whatever the hell that is) and it appears to be working now. Good ol logs save the day.
    – Louis W
    Sep 21 '10 at 21:55

rpm -qa|grep -i php-mysql check that out

  • php-mysql-5.2.14-2.el5.art
    – Louis W
    Sep 20 '10 at 14:59
  • vi /var/www/html/info.php <?php phpinfo(); ?> look for mysql support in php page
    – Rajat
    Sep 20 '10 at 15:16
  • PHP is compiled with the MySQL module, Client API version 5.0.90
    – Louis W
    Sep 20 '10 at 15:37
  • yum remove mysql mysql-server then install using yum install mysql mysql-server
    – Rajat
    Sep 20 '10 at 15:46
  • forums.mysql.com/read.php?35,64808,76338#msg-76338 one more link i could found which may help you!!
    – Rajat
    Sep 20 '10 at 15:48

You have to configure phpmyadmin to access you server.

Read faq 2.2 and 2.3 and also Setup script.

  • Something with PHP cause even this doesn't work: mysql_connect("localhost:3306","root","XXX");
    – Louis W
    Sep 20 '10 at 16:16
  • Maybe some permission problems. Look into log files or enable display PHP errors.
    – lg.
    Sep 21 '10 at 7:24
  • If you trying to connect via TCP connection, not via local socket, check that mysqld listens on that port (netstat -an | grep 3306). If it is not - remove skip-networking option from config file.
    – gelraen
    Jan 24 '11 at 12:56

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.