Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

this is a repost of my question at apple.stackexchange.com

I have installed MySQL via homebrew: brew install mysql. I'd like to get the MySQL preference pane hooked up to my installation of MySQL through homebrew. How can I achieve this?

share|improve this question

1 Answer 1

I've had the same issue. After googling my butt off, here's what I was able to find out:

  1. install symlinks to Homebrew's MySQL installation in /usr/local/mysql:

    mkdir -p /usr/local/mysql; cd /usr/local/mysql
    ln -s $(brew --prefix mysql)/* .
    

    (this already allows you to stop the MySQL Server using the button in that preference pane – because it simply uses the mysqladmin binary – but not to start it)

  2. The preference pane attempts to start the MySQL server as user mysql or _mysql rather than running it with your user name. They say it's a good idea to have a dedicated UNIX user for the SQL server anyway... Therefore the data directory must be owned by the user called _mysql or mysql as well.

    You can find out where your data directory is by looking for the entry datadir= inside /etc/my.cnf, or $HOME/.my.cnf, or $(brew --prefix mysql)/support-files/mysql.server, then chown it accordingly.

    Alternatively, you could start with a fresh data directory using mysql_install_db:

    unset TMPDIR
    sudo mysql_install_db --user=_mysql --basedir="$(brew --prefix mysql)" --datadir=/your/data/dir
    

    Note that, after installing it like this, you won't be able to start the MySQL server with your username anymore, at least not without sudo -u.

    If there's no user and/or group called _mysql on your system, you can create them using the dscl command line utility, as described here.

  3. To start MySQL server automatically on system start, you'll need to install the MySQL Startup Item, then activate the checkbox in the preference pane, and if you followed steps 1 and 2, on next reboot, it should work like a charm!

share|improve this answer
    
At first I can't use the start/stop button, then I uninstall the prefPane, redo all the step abover, then install the prefPane and it works. Thanks! –  TaianSu Aug 19 '12 at 5:10

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.