0

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.

3
  • What distribution? do you have the php-mysql package installed for it? Commented Sep 20, 2010 at 14:12
  • Yes I do, php-mysql-5.2.14-2.el5.art Commented Sep 20, 2010 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. Commented Sep 21, 2010 at 21:55

2 Answers 2

0

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

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

You have to configure phpmyadmin to access you server.

Read faq 2.2 and 2.3 and also Setup script.

3
  • Something with PHP cause even this doesn't work: mysql_connect("localhost:3306","root","XXX"); Commented Sep 20, 2010 at 16:16
  • Maybe some permission problems. Look into log files or enable display PHP errors. Commented Sep 21, 2010 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. Commented Jan 24, 2011 at 12:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.