November 2014: If you get this error in MySQL 5.6.x on Mac OS X Mavericks or Yosemite and want to use MySQL with PHP locally (/tmp/mysql.sock is where PHP PDO expects to find a sock file), here’s what fixed this for me:
1) Uncomment the standard lines of the homebrew configuration file and edit as shown below
$ sudo vi /usr/local/Cellar/mysql/5.6.21/my.cnf ... basedir = /usr/local/Cellar/mysql/5.6.21 datadir = /usr/local/var/mysql port = 3306 server_id = <UNIQUE_NUMBER_HERE_OR_LEAVE_COMMENTED_OUT> socket = /tmp/mysql.sock pid-file = /usr/local/var/mysql/[BOXNAME].local.pid ....
BOXNAME is what you have in your system Prefs → Network as a unique identifier for your computer on the network.
2) Set permissions for all files in datadir mysql. They all belonged to [my_username]. MySQL is very picky and refuses to create a pid file if it (user _mysql) does not own the directory.
$ sudo chown -R _mysql:mysql /usr/local/var/mysql
3) Start MySQL using the bash helper / shell script:
$ sudo mysql.server start Starting MySQL . SUCCESS!
Hope this helps. If the above does not work for you, try running the mysqld_safe binary manually in the Cellar / mysql / VERSION_ / bin / directory and check what settings (if it is running)
sudo /usr/local/Cellar/mysql/5.6.12/bin/mysqld_safe &
If this is done, you can
ps aux | grep mysql
and see something like
[username] 6881 0.0 2.7 3081392 454836 ?? S 8:52AM 0:00.54 /usr/local/Cellar/mysql/5.6.21/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.21 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.21/lib/plugin --verbose --log-error=/usr/local/var/mysql/BOXNAME.local.err --pid-file=/usr/local/var/mysql/BOXNAME.local.pid
I'm not sure why this worked for me, but it shows you where I got the settings for my.cnf configuration file from. You can also use command line options to try to troubleshoot mysqld manually.
If you are managing a MySQL server using mysqld_safe, you may need to do this to close it before trying to use the mysql.server bash helper. Eliminate the urge to kill -9 [PID] because you can damage your data.
mysqladmin -uroot shutdown
Good luck
phpguru Nov 24 '14 at 17:19 2014-11-24 17:19
source share