I am getting the dreaded error when accessing http://localhost/drupal:
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Library/WebServer/Documents/drupal/includes/database.mysql.inc on line 31
Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
Here's the info:
I'm installing on OS X 10.4, drupal 4.6.5, mysql 5 (I've also tried with mysql 4.1, same problem).
The weird thing is, I had drupal running just fine off of my local machine (all I want to do) a month ago, and it mysteriously stopped working and all I can get is that error. My settings.php file is setup correctly, I'm sure. I am able to access the drupal database in mysql with the drupal user using MySQL Query Browser, so I know the mysql server is running fine (mysqld running). Strangely enough, I get the same error whether the mysql server is running or not.
I've read every forum topic on this tonight, and no solutions seemed to help. I got excited when I discovered there is no directory /var/mysql/ on my machine--my mysql.sock appears to be located in /tmp -- I tried creating a symbolic link as someone else had suggested to no avail. I feel like this might be where the problem lies though. Is there any way I can tell drupal to not look in /var/mysql and to look in /tmp for mysql.sock aside from the symbolic link?
The annoying thing is, drupal is running just fine on my site5 webserver. I just want to run it locally on my own machine so I can develop my site's theme without having to load things onto the server.
Any help from anyone would be so excellent, I am going insane.
Comments
this is mysql client issue, so....
Can you update your mysql configfile (my.cfg) as in http://dev.mysql.com/doc/refman/4.1/en/problems-with-mysql-sock.html.
This shows where the server puts the socket file and where the client should go to find it.
Goof Luck,
Paddy.
http://deburca.org, and http://amadain.net
Paddy.
http://deburca.org
The version of PHP that
The version of PHP that Apple included with Mac OS X 10.4.4 has mysql.default_socket set to "/var/mysql/mysql.sock", before it was "/tmp/mysql.sock". They change it for some security reasons I believe.
The binary version of MySQL from mysql.com use "/tmp/mysql.sock" so one has to change.
I choose to make PHP look for "/tmp/mysql.sock" by setting this in /etc/php.ini.
I also tried to go the other way by setting this in /etc/my.cnf.
Both work but I went with the first solution because the second one made the MySQL preference pane stop working.
thanks
thank you both for replying--I will try all of these fixes tomorrow when I have access to my home machine--hopefully one of them will work
hmm
frjo,
I tried your first change and it didn't seem to work. Although there was a condition--I only have php.ini.default in /etc not php.ini, although I tried editing the .default version with the change, as well as renaming it php.ini with the change, and neither worked.
Mysteriously enough, I also don't have any file called my.cnf in /etc, not even a .default version. Could this be the problem?
You need to create the file(s)
You need to create the file(s) "/etc/php.ini" and/or "/etc/my.cnf" yourself.
When MySQL and PHP don't find any settings files they simply use the default values.
"php.ini.default" is a example php.ini file, you can make a copy of it and rename it to "php.ini" if you like.
Remember to read the comment at the top of "php.ini.default" first!
If you bare with me, I will check this evening
I have Mac OSX, mySQL and drupal running at home. If you bare with me I will gather all the information I can find and include it in a post.
How is your mySQL started ? as a deamon?
Can you look in /Library/StartupItems/{something-like-mysql} and have a look at the start-up script. It may give you the location of the .cnf files to look for and may also point you to the location of a default version.
Paddy.
http://deburca.org, and http://amadain.net
Paddy.
http://deburca.org
I'm starting up mysql via
I'm starting up mysql via the mysql prefpane. When I look at activity monitor, it says mysqld is up and running fine.
I don't have mysql coming on at startup, so there's nothing in that folder currently.
If I'm going to create a my.cnf file, what do I put in it? Can I just put that one line about the socket, and then assume the rest will go to defaults?
Any help you have about your system would be great. I can't believe this still isn't working, when it used to work on my computer just fine.
Thanks
Well, as these things often
Well, as these things often do with me, it came down to stupidity.
After editing php.ini with the change frjo mentioned, I was restarting mysql and not apache before trying again. Restarting apache seemed to do it.
I also changed the priveleges of /tmp so www could read it by doing this at the terminal, so that might have helped too:
sudo chmod 775 /tmpThere is extensive confusion on this topic (upgrades to 10.4.4 mucked around with the mysql.sock location, it seems) and here are some links from apple and others:
http://docs.info.apple.com/article.html?artnum=301457
http://docs.info.apple.com/article.html?artnum=302977
http://www.afp548.com/article.php?story=20051204002042215
http://forums.mysql.com/read.php?20,37144,66425#msg-66425
Thanks so much to everyone for helping. Really.
I am a little bit confused..
On my system, /tmp is a symbolic link to /private/tmp, and /private/tmp has a permission of
Now the 't' at the end signifies a sticky bit man 8 sticky gives
I think that a
is more correct.
Paddy.
http://deburca.org, and http://amadain.net
Paddy.
http://deburca.org
Thank-you
Grrrrr.
I have been wondering what stupid thing I did to break my mac for the last week or so. I have been looking for answers everywhere. Thrilled to find the answer right under my nose.
Development manager CivicSpace Labs
Kieran Lal
ran into this issue on 10.6
ran into this issue on 10.6 server
documented my workaround here:
https://drupal.org/comment/8443467#comment-8443467