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. Post a comment or leave a trackback: Trackback URL.

3 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 !!!!!!!!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">