Resolution to Mac OSX Update Which Causes PHP and MySQL To Stop Talking

Upon restarting from the lastest couple of automatic Leopard updates from Apple PHP could no longer connect to MySQL, giving the error:

Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)

What this means is it can't find mysql.sock OR it's not finding the database ip you specified in your connection code. So, try this first:
- replace "localhost" with "127.0.0.1" in your PHP

If that doesn't work, you probably need to create a virtual linked file from /var/mysql/mysql.sock to /private/tmp/mysql.sock (where you are bound to have one):

1. Fire up the Terminal application
2. Type:
cd /var
ls

3. If you DO NOT have a mysql directory already in here type:
sudo mkdir mysql

4. Do the important bit:
cd mysql
sudo ln -s /private/tmp/mysql.sock mysql.sock

5. If you get a mysql_connect Access denied for user type error subsequently, try:
GRANT ALL PRIVILEGES ON database_name TO user@host IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Comments

Popular posts from this blog

Installing LAMP Apache/MySQL/PHP on Chromebook/Chromebox

Installing Ubuntu Linux on your ChromeBox/ChromeBook

Changing your Mac OSX Terminal's default text editor