MySQL Error 2002 - Can't connect through socket '/tmp/mysql.sock' on 64-bit, with a botched 32-bit uninstall complicating things

Matthew Du Pont picture Matthew Du Pont · May 2, 2012 · Viewed 10.7k times · Source

I'm new to Macs/MySQL, and am struggling to get MySQL working. I'm on 64-bit Lion, and first attempted to install the 32-bit MySQL from the command line. I then attempted to remove it and replace it with the 64-bit DMG, but the results of mysql -V indicate the 32-bit may still be around in some form. I get 2002 errors when trying to run MySQL-related commands, but Python's MySQLdb works fine. Below is more information; please let me know how to get this working.

I'm aware that some sort of linking is usually used to resolve the problem, but I can't find an answer that fits my file structure. I will try to be very responsive to asks for more information. Thanks!

bash-3.2$ mysql -V
mysql  Ver 14.14 Distrib 5.1.62, for apple-darwin10.3.0 (i386) using readline 5.1

bash-3.2$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

bash-3.2$ mysqld
120501 20:21:42 [Warning] Can't create test file /usr/local/mysql-5.1.62-osx10.6-x86_64/data/MDP-main.lower-test
120501 20:21:42 [Warning] Can't create test file /usr/local/mysql-5.1.62-osx10.6-x86_64/data/MDP-main.lower-test
mysqld: Can't change dir to '/usr/local/mysql-5.1.62-osx10.6-x86_64/data/' (Errcode: 13)
120501 20:21:42 [ERROR] Aborting
120501 20:21:42 [Note] mysqld: Shutdown complete


bash-3.2$ ls /usr/local
MySQL-python-1.2.3              mysql
bin                             mysql-5.1.62-osx10.6-x86_64
etc                             share
git

And my bash path:

PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql-5.1.62-osx10.6-x86_64/bin      
export PATH

Edit 1: In response to the "permissions" suggestion, it doesn't seem to work in current form:

bash-3.2$ chown -R mysql.mysql /usr/local/mysql
chown: mysql.mysql: Invalid argument

In that directory:

bash-3.2$ ls -a /usr/local/mysql
.               README          include         scripts
..              bin             lib             share
COPYING         data            man             sql-bench
INSTALL-BINARY  docs            mysql-test      support-files

Answer

Ciprian Lungu picture Ciprian Lungu · May 2, 2012

Its a permission problem. try:

chown -R mysql.mysql /usr/local/mysql

replace "." with ":" from the last post

 chown -R mysql:mysql /usr/local/mysql
./usr/local/mysql/bin/mysqld stop
./usr/local/mysql/bin/mysqld start

http://support.apple.com/kb/ht2963