Install MySQL on Mac OS X 10.6 and add StartupItem

Installing MySQL on Mac OS X 10.6 took a bit of digging around. Here is a consolidated tutorial. I am leaving out sudo commands for convenience. Use them where you don’t have permission.

# create the directory where you will keep your MySQL binary distribution
mkdir ~/src
cd ~/src
 
# download mysql binary distribution from http://dev.mysql.com/downloads/mysql/
# then move the distribution into your src directory
mv /path/to/mysql/download.tar.gz ~/src
# make sure you are in ~/src (use pwd if unsure) then untar
gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
 
# create the MySQL group
dscl . create /Groups/mysql
# give it some group id
dscl . create /Groups/mysql gid 296
# create a MySQL user
dscl . -create /Users/mysql
# make the MySQL user a member of the MySQL group
dscl . append /Groups/mysql GroupMembership mysql
# change ownership to mysql
chown -R mysql .
chgrp -R mysql .
 
# install mysql
scripts/mysql_install_db --user=mysql
# make a symlink in the /usr/local directory or you can customize the location in support-files/mysql.server if you prefer
mkdir /usr/local
cd /usr/local/
ln -s /full/path/to/your/mysql/install/directory mysql
 
# you should now be able to start the server
support-files/mysql.server start
 
# add mysql to your PATH
# in ~/.bash_profile
export PATH=/usr/local/mysql/bin:$PATH
source ~/.bash_profile
# should bring up the mysql CLI
mysql
# exit 
mysql> exit
 
# set mysql server to auto start upon boot
mkdir /Library/StartupItems/MySQLCOM
cd /Library/StartupItems/MySQLCOM/
ln -s /usr/local/mysql/support-files/mysql.server MySQLCOM
 
# test for success
/Library/StartupItems/MySQLCOM/MySQLCOM stop
/Library/StartupItems/MySQLCOM/MySQLCOM start
 
# create a root password
mysqladmin -u root password your_root_password
No TweetBacks yet. (Be the first to Tweet this post)
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

If you enjoyed this post, make sure you subscribe to my RSS feed!

This entry was posted in Software and tagged , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.

27 Comments

  1. Steve
    Posted May 18, 2010 at 8:10 pm | Permalink

    Hi Tony thanks for the info.

    I actually ran into a problem here:
    support-files/mysql.server start

    Got the following message
    bash: support-files/mysql.server: No such file or directory

    Then I tried:
    sudo: support-files/mysql.server: command not found

    And got this message
    sudo: support-files/mysql.server: command not found

    I’m using a MacBook Air. 10.6.3. On older machines I installed using binaries and never had a problem but this time it’s a real ball ache.

    Any suggestions much appreciated, thanks.

  2. Aaron
    Posted May 24, 2010 at 2:37 am | Permalink

    First, thank you, this is helpful.

    I ran in to a problem, though… everything worked until I restarted my machine, and noticed that mysql was not running. I tried running it myself

    /Library/StartupItems/MySQLCOM/MySQLCOM stop

    but got the error

    . ERROR! Manager of pid-file quit without updating file.

    then I realized I could only start mysql with the sudo command. Not sure why, because I know when I installed mysql I was able to run it with my staff user account.

    Either way, I would have though on start up, my mac would execute the startup items with root access. Maybe I’m wrong about this?

  3. Posted May 30, 2010 at 7:45 pm | Permalink

    thank u so much !! useful information !!!!!!!!

  4. Serjio
    Posted September 7, 2010 at 1:37 pm | Permalink

    it worked for me on 10.4!
    great tutorial!
    although I messed up with mysql groups just prior to when I found this article.
    when I do ls – l in my mysql folder i see:

    -rw-r–r– 1 kato mysql 17987 Sep 7 22:33 COPYING
    -rw-r–r– 1 kato mysql 5139 Sep 7 22:33 EXCEPTIONS-CLIENT

    so I guess kato is group name, however, I issued a command to add mysql to mysql group…

  5. Posted September 7, 2010 at 10:22 pm | Permalink

    @Serjio worked on 10.4? Nice. Maybe I should change the title.

    If anyone uses this tutorial to install successfully on other OS X versions than 10.6, please leave a comment.

  6. priya
    Posted September 12, 2010 at 7:58 am | Permalink

    i am beginner mac user. just have bought new macbook. i want to install mysql on it without headache. i tried ur steps but could not install it. please help me out. i got stuck on very first step – mv /path/to/……..

    i want more details.

    will you please reply me as soon as possible ?

  7. Posted September 12, 2010 at 11:50 am | Permalink

    @priya Just move the downloaded tarball to whatever directory you will keep sources. I like ~/src but you can put it wherever you want.

  8. priya
    Posted September 12, 2010 at 2:05 pm | Permalink

    Hey Tony Thank you very much….
    I have done it..
    thanks for your help.
    I have done with installation and now i want to connect ECLIPSE and MySQL,
    so will you please help me more in this area?

  9. Posted September 12, 2010 at 2:43 pm | Permalink

    @priya Sorry that is not my area of expertise. Best of luck!

  10. David
    Posted September 15, 2010 at 1:30 pm | Permalink

    Hi Tony!
    Thanx 4 the Tut
    I tried to make User and Group by dscl
    but it work only for Group… Biz
    I cudn’t chown mysql because every time the result -> nobody.
    So after create Group mysql with dscl…
    best go in System Preferences -> Accounts and make
    new user mysql and check on the right Group -> mysql
    With that I cud finally chown mysql :? )

  11. Posted September 17, 2010 at 10:41 pm | Permalink

    Perhaps I missed the point of this article, but why not just download the dmg file, which has the package installer for MySQL and another package installer for the startup item.

    Both are on the MySQL download site, and installation is two double-clicks away.

  12. Posted October 21, 2010 at 6:54 pm | Permalink

    Aloha! celebrex 100mg

  13. Posted November 14, 2010 at 1:10 am | Permalink

    how to buy Levlen online 1 viagra dosing for pulmonary arterial hypertension buying InnoPran XL online uk 6 viagra how often cheap sale Dipyridamole 5 caffeine neurons Hytrin saturday delivery 2 does caffeine help release stress KamaSutra LongLast Condoms best buy 4 mobic tab buy Diflucan in china 9 baby motrin buy Cialis Super Active Plus online purchase 5 ivermectin medicine for scabies buy cheap Avapro 6 celexa gad fedex overnight Generic Keflex 6 health benefits of quitting caffeine cheapest Cardura uk cheap 9 zoloft treatment of anxiety
    Extreme Thyrocin cash delivery 2 nexium no prescription buy Hoodia Weight Loss Gum cheap 8 kid zantac Entocort next day no prescription 2 time caffeine is in breastmilk Brand Amoxil cod delivery 9 hotel amaryl berlin how to get a Diovan prescription 4 what classifcation of pyridium buy Amaryl us online 6 how is imitrex administered cheap generic overnight Bactrim 6 coke zero caffeine free KamaSutra Intensity Condoms KamaSutra Intensity Condoms 7 viagra quick delivery buy Celebrex next day delivery 9 drug lopressor Acticin overnight 6 basics ramipril

  14. Chinmay
    Posted December 15, 2010 at 4:34 am | Permalink

    @Scott Davey
    I bought a new macbook pro 64 bit. I have been trying to get mysql working using the .tar. Failed. It was until I read your comment on this page, that I realized how easy everything becomes once you use the .dmg on the same page.
    I got everything up and running in 5 minutes. Thanks a ton! :)
    The preferences pane icon rocks too!

  15. Posted January 13, 2011 at 10:55 am | Permalink

    Dude. Thank you. My local SQL was fazooked for a bit after the upgrade. Your steps worked splendidly. Back to the sandbox!

  16. David
    Posted January 20, 2011 at 8:47 am | Permalink

    @Steve:

    “I actually ran into a problem here:
    support-files/mysql.server start”

    At that point, your actually in /usr/local, so you need to add mysql to the front of the command so that it will use the symlink you just created:

    mysql/support-files/mysql.server start
  17. Posted January 20, 2011 at 2:27 pm | Permalink

    I agree with the post above and I will get more information from google

  18. Alfredo
    Posted February 27, 2011 at 9:59 pm | Permalink

    Hey Tony – great article! I couldn’t get the dmg to work so I tried this and it works following your instructions step by step. Thanks so much!

    AA

  19. Gergely Papp
    Posted March 9, 2011 at 8:45 am | Permalink

    @Tony: this is really a great tutorial, things went like a charm! :) Thanks!

    @Aaron: I also have the same problem: things won’t start up when my mac is rebooted. Is there any solution to that?

    Just to recapitulate, mysql is not started at startup, even though the start script is placed in the /Library/StartupItems library, and mysql can be started using sudo only.

    Thanks in advance!

  20. potri
    Posted June 12, 2011 at 10:58 am | Permalink

    @tony
    I was able to go until chgrp -R mysql .

    But I have not been able to install mysql using the command “scripts/mysql_install_db –user=mysql” it says file not found.

    Moreover, when I restarted Mac, all my original settings are gone and I am logged in as a new user every time (I guess) with no permission to my own folders and the configurations I made in my applications.

    Any help to restore my original user setting is highly appreciated!

    Thanks,
    -Potri

  21. Posted June 26, 2011 at 3:39 pm | Permalink

    Great tutorial, Tony.

  22. Poorva
    Posted July 18, 2011 at 6:32 pm | Permalink

    Hi Tony,

    Thanks a Ton for this article!!

    But unfortunately I am running in to a problem when I try to create mysql group user

    # create the MySQL group
    dscl . create /Groups/mysql

    it throws me the following error:

    “Cannot open remote host, error: DSOpenDirServiceErr”

    Any help is highly appreciated!!!

  23. me
    Posted October 3, 2011 at 6:22 am | Permalink

    bad bad bad

  24. Posted November 10, 2011 at 5:17 pm | Permalink
  25. Posted November 18, 2011 at 12:02 am | Permalink
  26. Posted January 5, 2012 at 12:23 am | Permalink
  27. Jonathan Greenleaf
    Posted August 7, 2012 at 10:55 am | Permalink

    these instructions did not work for me.

    sudo support-files/mysql.server start
    Starting MySQL
    … SUCCESS!
    export PATH=/usr/local/mysql/bin:$PATH
    source ~/.bash_profile
    mysql
    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)