Installing MySQL 5.1 on Mac OS X 10.7 (Lion)

MySQLosx lion

I am trying to install MySQL 5.1. I am on Lion, and when I remove all files associated with MySQL on my machine it still tells me that I have a newer version installed when I try to install it from the DMG file.

Has anyone successfully installed MySQL 5.1 on Lion?

I found a solution using Homebrew:

  1. Completely remove MySQL from your system (just in case)

    sudo rm /usr/local/mysql
    sudo rm -rf /usr/local/mysql*
    sudo rm -rf /Library/StartupItems/MySQLCOM
    sudo rm -rf /Library/PreferencePanes/My*
    vim /etc/hostconfig and removed the line MYSQLCOM=-YES-
    rm -rf ~/Library/PreferencePanes/My*
    sudo rm -rf /Library/Receipts/mysql*
    sudo rm -rf /Library/Receipts/MySQL*
    sudo rm -rf /var/db/receipts/com.mysql.*
    

    Source:https://stackoverflow.com/questions/1436425/how-do-you-uninstall-mysql-from-mac-os-x

  2. Install homebrew

    /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
    

    Source: https://github.com/mxcl/homebrew/wiki/installation

  3. Install MySQL 5.1 via brew

    brew install mysql51

    if that doesn't work, do this:

    brew install https://raw.github.com/adamv/homebrew-alt/master/versions/mysql51.rb

    Source: https://stackoverflow.com/questions/4359131/brew-install-mysql-on-mac-os/6399627#6399627

  4. Make MySQL Work
    1. Create mysql.sock file
      touch /tmp/mysql.sock
    2. Install MySQL default tables

      /usr/local/Cellar/mysql51/5.1.58/bin/mysql_install_db

      …or your path

Best Answer

Have you tried this.

Download the 64-bit DMG version of MySQL 5.1.x (or 5.5.x) for Mac OS X 10.6 from the official MySQL site and install the package, the startup item and the preference pane.

Add /usr/local/mysql/bin to the path:

vim ~/.bash_profile

And add:

export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH
export EDITOR=vim

At the top of file. (Note that we set EDITOR whilst we are here so that svn is happy!)

Set up MySQL root password:

mysqladmin -u root password {new-password}
mysqladmin -u root -p{new-password} -h localhost password {new-password}
mysqladmin -u root -p{new-password} reload

Clear the history file by typing history -c so that {new-password} isn't in plain text on the disk.

Now ensure that the mysql.sock file can be found by PHP: Ensure that MySQL is running

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Related Question