Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I followed this tutorial to install MySQL on Mac OS X 10.6.8. Now I get he following errors:

$ mysqladmin version
/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
$ ls /tmp/mysql.sock
ls: /tmp/mysql.sock: No such file or directory

And

$ /Library/StartupItems/MySQLCOM/MySQLCOM stop
Stopping MySQL database server
$ /Library/StartupItems/MySQLCOM/MySQLCOM start
Starting MySQL database server
$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

And

$ mysqladmin ping
/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
$ mysqladmin -uroot ping
/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
$ mysqladmin -uroot -h127.0.0.1 ping
/usr/local/mysql/bin/mysqladmin: connect to server at '127.0.0.1' failed
error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 61'
$ mysqladmin -uroot -h127.0.0.1 --protocol=tcp ping
/usr/local/mysql/bin/mysqladmin: connect to server at '127.0.0.1' failed
error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 61'
$ ls /usr/local/mysql
mysql/                       mysql-5.0.95-osx10.5-x86_64/ 
$ ls /usr/local/mysql/
COPYING         README          configure       docs/           lib/            mysql-test/     share/          support-files/  
INSTALL-BINARY  bin/            data/           include/        man/            scripts/        sql-bench/      tests/          
$ find /usr/local/mysql/ -name mysql.sock
find: /usr/local/mysql//data: Permission denied
$ sudo find /usr/local/mysql/ -name mysql.sock
Password:
$

Also, I can't login MySQL:

$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
$ mysql -uroot -h127.0.0.1
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)
$ mysql -uroot -h127.0.0.1 --protocol=tcp
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)

And

$ /Library/StartupItems/MySQLCOM/MySQLCOM stop 
Stopping MySQL database server
$ /Library/StartupItems/MySQLCOM/MySQLCOM start --skip-grant-tables
Starting MySQL database server
$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
$ sudo ls -l /usr/local/mysql/data/*.err
Password:
ls: /usr/local/mysql/data/*.err: No such file or directory

Re: @Matt Fenwick

$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
Stopping MySQL database server
$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
Starting MySQL database server
$ sudo mysqld -u root
120327 13:03:48 [Warning] Ignoring user change to 'root' because the user was set to 'mysql' earlier on the command line

120327 13:03:48 [Warning] Setting lower_case_table_names=2 because file system for /Volumes/storage/Data/ is case insensitive
$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
$ sudo mysqld -u mysql
120327 13:04:11 [Warning] Setting lower_case_table_names=2 because file system for /Volumes/storage/Data/ is case insensitive
$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
$ 

my.cnf used

[mysql]
max_allowed_packet=128M
socket=/tmp/mysql.sock
[mysqld]
user=mysql
datadir=/Volumes/storage/Data
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#socket=/var/lib/mysql/mysql.sock
socket=/tmp/mysql.sock
innodb_log_file_size=256M
skip-locking
skip-bdb
delay-key-write=OFF
interactive_timeout=3600
wait_timeout=3600
thread_cache_size=128
table_cache=2048
skip-external-locking
max_connections=800
key_buffer_size=64M
read_buffer_size=1M
sort_buffer_size=2M
join_buffer_size=1M
read_rnd_buffer_size=2M
bulk_insert_buffer_size=10M
tmp_table_size=64M
max_heap_table_size=64M
max_connect_errors=5000
max_allowed_packet=128M
innodb_data_file_path=ibdata1:256M:autoextend
innodb_buffer_pool_size=1G
innodb_log_file_size=512M
innodb_flush_log_at_trx_commit=2
innodb_open_files=1000
share|improve this question
    
If you followed that guide to the letter, what does /Library/StartupItems/MySQLCOM/MySQLCOM status return? –  Phil Mar 14 '12 at 16:05
    
Also, try mdfind mysql.sock to locate mysql.sock, as it may be creating it in another directory –  Phil Mar 14 '12 at 16:09
    
Output for MySQLCOM stop and MySQLCOM start are pasted in OP. –  Problemania Mar 14 '12 at 16:16
    
Also, mdfind mysql.sock revealed nothing relevant, AFAICT. –  Problemania Mar 14 '12 at 16:21
    
Sounds like it's not running. What does ps auxww | grep -i mysqld | grep -v grep return ? –  Phil Mar 14 '12 at 16:26

3 Answers 3

I had this exact same problem (although I'm on Mac OS X 10.5.8) with all the same error messages.

It turned out the problem was that when the computer was turned on, MySQL was not started automatically.

I solved it by manually starting MySQL:

prompt$ sudo mysqld -u root <secure password goes here!>

Note the sudo: MySQL wouldn't let me start up the server without root access to both the computer and MySQL itself (not that I'm complaining, but it was just frustrating until I figured that out). Also note that the program is mysqld, not mysql.

After running that command, everything works fine for me.

share|improve this answer
    
Your method still doesn't seem to fix the issue. See error message in OP. –  Problemania Mar 27 '12 at 18:06
    
@user6076 what doesn't work? My error messages are exactly the same as yours, until I follow my procedure. Do you not have either root password? What is the output from sudo mysqld -u root? –  Matt Fenwick Mar 27 '12 at 18:09
    
See at the bottom of OP. –  Problemania Mar 27 '12 at 18:11

If you have installed MySQL server using the disk image (.dmg) file then:

Using the Terminal application (bash):

sudo su -
nohup /usr/local/mysql/bin/mysqld_safe &
exit
share|improve this answer

I had a similar experience and realized I was forgetting the "sudo" in front of the "/Library/StartupItems/MySQLCOM/MySQLCOM start" command. Without sudo, it looks like the command completes, but the server isn't running and processes don't start up. As soon as I added sudo, everything fired up as expected.

share|improve this answer
    
This has already been mentioned twice in other (much earlier) answers and is covered in edits to the original question. –  Paul White Oct 27 '12 at 1:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.