Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm moving a website (php/mysql) from an Ubuntu server to a OSX 10.6 server. I've set up apache to run php scripts and setup the newest version of mysql on the mac. I just copied all of the php files and dumped/imported all of the mysql databases (including the mysql users database).

When I visit the page being served on the Mac the page is able to connect to the database, but not query. Specifically this function


is returning this error message


The reason it's strange is that I'm able to change the php connection strings for mysql on the Ubuntu server so that it points to the Mac server and the page works correctly (so it seems mysql is correctly set up on the mac and definitely contains all of the users and tables it should).

Thinking it was something to do with file permissions on the mac, I've changed all of the files 755 and it hasn't helped.

Any ideas? Thanks!!

UPDATE: I've found this error which I'm relatively certain is related to this problem in /var/log/apache2/error_log

PHP Warning:  mysql_query(): A link to the server could not be established
share|improve this question
up vote 0 down vote accepted

"NO SUCH FILE OR DIRECTORY" look like web server error. If use mysql_error() to returns the text of the error message, copy all error message with error code:


if you don't use mysql_error(), add mysql_error() call after problem mysql_query().

PHP can't connect to MySQL. Add check after mysql_connect():

mysql_connect(..) or die('Could not connect: ' . mysql_error());
share|improve this answer
Thanks for your reply! I just updated the question, I meant to say that mysql_error() was returning that error message. It does sound like a web server error more than an mysql error so I'm not sure what to make of it. – evan Feb 24 '11 at 22:59
Try add check mysql_connect() and run mysql client from console. – ooshro Feb 24 '11 at 23:21
Yup all I had to do was cat the connect.php I wrote... I was messing with sed earlier and it ended up <?phpphp instead of <?php :)... thanks for your help! – evan Feb 24 '11 at 23:25
So the issue was for anyone else who gets this error - I was trying to query with out first connecting. – evan Feb 24 '11 at 23:26

Is that error message returned from the mysql_query call or something you find in the mysqld log or somewhere else? If the former, you could use 'dtruss' either on the web server process(es) itself (which can be tricky to do) or on a stripped-down version of your code run with php-cli. 'dtruss' will let you see what files it is trying and failing to open.

share|improve this answer
Thanks for your help. I haven't had a chance to play with dtruss, but I did update my question with an error that seems along the same lines as what you think the problem is. – evan Feb 24 '11 at 23:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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