Saturday, January 29, 2011

MySQL on Mac OS X Issues

I installed MySQL from:

http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg

I am on OS X 10.5.8. I open Terminal and do:

cd /usr/local/bin

then:

mysql -u root

I get the following error:

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

I have spent the last 2 hours scouring sites looking for an answer that makes sense. This is a brand new laptop. I am at a loss. Here is my .bash_profile:

export PYTHONPATH=/Users/blwatson/pythonpath;/Users/blwatson/pythonpath/bin:$PYTHONPATH

# Setting PATH for MacPython 2.6
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}"
export PATH
export

PATH=/usr/local/mysql/bin:/Library/Frameworks/Python.framework/Versions/2.6/bin:/Library/Frameworks/Python.framework/Versions/2.6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

I am at a loss. The install order was:

1) Django 2) Python 2.6 3) MySQL 5

  • Did you start MySQL?

    BrandonWatson : I don't know enough to answer that question.
    Adam Jacob Muller : Well, if you don't know if you started it, you probably didn't. ps aux|grep mysql if you didn't install the system preference pane off the DMG, do that, and use it to start MySQL.
  • To start MySql go to System Preferences > MySql > Start

    BrandonWatson : I do not see MySql in the System Preferences
    RickyAH : Because that option is added to the System Preference panel if you install the MySQL package from the official site.
    From Umesh
  • Check that the socket exists at /tmp/mysql.sock. If not, start mysql

    sudo /usr/local/mysql/bin/mysqld_safe
    

    Then try logging into the mysql client

    /usr/local/mysql/bin/mysql -u root
    
    BrandonWatson : OK...so you now have me running. First, thank you. Second, what did you do exactly? Third, will I have to run that mysqld_safe command every time? I am a Windows guy and new to dev environment on Mac OS X. Quick learner, but still learning.
    Stu Thompson : In the DMG is a file called *MySql.prefPane*. Run that and it will install a System Preferences pane that lets you control whether or not MySql starts on boot.
    BrandonWatson : Wow...3 hours of frustration reduced to 6 lines of answers from ServerFault users. Thanks guys. Now I just have to sort out how to get PythonMySQL sorted.
    the_snitch : I have found the mysql prefpane to be somewhat broken on 10.5, and I havn't even bothered with it on 10.6 (as it will be 32-bit). A better solution to autostart mysql is to create a launch daemon and submit it to launchd as described here: http://www.macosxhints.com/article.php?story=20080128103022907
    From the_snitch

0 comments:

Post a Comment