Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

mySQL can't connect

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

Mac mini, Mac OS X (10.7.3)

Posted on Apr 15, 2012 1:11 PM

Reply
12 replies

Apr 15, 2012 2:39 PM in response to etresoft

after that I get this:

Administrators-Mac-mini:~ administrator$ mysql

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

Administrators-Mac-mini:~ administrator$


I did not uninstall & start over, just this part:

Create a launchd config file for MySQL:

sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist


Use the following content:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>KeepAlive</key>

<true/>

<key>Label</key>

<string>com.mysql.mysqld</string>

<key>ProgramArguments</key>

<array>

<string>/usr/local/mysql/bin/mysqld_safe</string>

<string>--user=mysql</string>

</array>

</dict>

</plist>


(if you are new to vi, type 'i' to enter insert mode. Then ⌘-v to paste the above content. Press escape to get back to command mode. Then type 'ZZ' to save and exit.)


The default path for the MySQL socket is not appropriate for MacOS X. Until it is changed, MySQL will not be able to communicate with PHP should you choose to enable that. Let's fix this now.


Create a config file for MySQL that matches the Apple PHP build:

sudo vi /etc/my.cnf


Use the following content:

[client]

socket=/var/mysql/mysql.sock


[mysqld]

socket=/var/mysql/mysql.sock


Start MySQL:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist


Still No Joy.

Nav

Apr 16, 2012 5:14 PM in response to TheNavigator500

Have you actually installed and started the server?


What do you get when you type:


ps auxww | grep mysql


_mysql 158 0.0 0.5 2669012 39548 ?? S Sun06pm 0:06.79 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/localhost.err --pid-file=/usr/local/mysql/data/localhost.pid --socket=/var/mysql/mysql.sock

root 62 0.0 0.0 2433432 1004 ?? Ss Sun06pm 0:00.03 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql

jdaniel 5269 0.0 0.0 2432764 600 s002 R+ 8:14pm 0:00.00 grep mysql

Mar 11, 2013 2:41 PM in response to etresoft

Hi etresoft: I followed your tips from https://discussions.apple.com/docs/DOC-3082 and I bump into the same problem that Navigator500 got. I keep getting the error message, "mysql unable to connect; MySQL said: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)" . I tried typing "ps auxww | grep mysql" and got the following:


root 576 0.0 0.4 2550132 16544 ?? S 2:17PM 0:01.41 /Applications/TextEdit.app/Contents/MacOS/TextEdit /usr/local/mysql/support-files/mysql.server

root 575 0.0 0.1 2466676 4752 ?? S 2:17PM 0:00.02 sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /usr/local/mysql/support-files/mysql.server

_mysql 221 0.0 2.1 2722944 88948 ?? S 1:55PM 0:01.50 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/Crystals-MacBook-Air.local.err --pid-file=/usr/local/mysql/data/Crystals-MacBook-Air.local.pid

root 114 0.0 0.0 2433436 1004 ?? S 1:55PM 0:00.03 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/Crystals-MacBook-Air.local.pid

user1 11182 0.0 0.0 2432768 596 s000 R+ 2:39PM 0:00.00 grep mysql


Can you give me some guidance on what the issue is? I am a newbie to SQL and programming. Sorry if my questions sound dumb and silly!

mySQL can't connect

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.