Jump to content

[SOLVED] php no longer connects


bluethundr

Recommended Posts

Hi

 

I have php 5.3.0 installed on my snow leopard mac. mysql 5.1 is installed and running. everything is local. I can log into mysql from the command line but for some reason even tho I am feeding my php scripts the correct login and they used to work they can no longer connect to my local mysql install.

 

I could use some help troubleshooting this.

 

Specifically this line used to work:

 

if (!($connection = @ mysql_connect("localhost","user","shhhhh")))
          die("Could not connect");

 

now this script jumps right to the die line.

 

I'm honestly not sure what changed here.

:shrug:

help!

 

Link to comment
Share on other sites

these are the permissions on my my.cnf which lives in /private/etc on the mac

 

mazdayasna:etc bluethundr$ ls -la my.cnf
-rw-r--r--  1 root  wheel  10 Nov 10 14:10 my.cnf

 

also I've noticed that it is empty, except for the statement [mysqld]

 

I tried to add the large packets directive in my.cnf

 

max_allowed_packet=32M

 

but then mysql wouldn't launch. so I removed it, and it started launching again. I think this is when php stopped being able to connect.

 

I noticed when I installed mysql on my mac, unlike my linux boxen the my.cnf is curiously empty.

Link to comment
Share on other sites

Well I just fixed this problem with the help of spox on #php on freenode.

 

 

The mac install of MySQL does not conform to all the "usual" locations you are used to on a linux install. The most important things you have to change in your php.ini file are where the sock lives.

 

On linux any reference to mysqld.sock in your ini file should point to /var/run/mysqld/mysqld.sock

On the mac you need to change those references to /opt/local/var/run/mysql5/mysqld.sock

 

But the most important thing in my case in solving this problem was adding the line mysql.default_socket = /tmp/mysql.sock (which was missing in my ini file) and resetting mysqli.default_socket to mysqli.default_socket = /tmp/mysql.sock.

 

This was the source of the WIN after struggling for a week. THANKS SPOX!!!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.