Skip to content

Install MySql5 on Snow Leopard using MacPorts

Install MacPorts before you do anything.

Install MySQL5

sudo port install mysql5
sudo port install mysql5-server 
sudo -u mysql mysql_install_db5

Secure MySQL5

To secure your MySQL5 installation, you can either change the password manually like so:

/opt/local/lib/mysql5/bin/mysqladmin -u root password {new-password}

or on a production system, you can run the secure script and not only change the password, but remove anonymous access and prevent remote root login.

/opt/local/lib/mysql5/bin/mysql_secure_installation

To start the MySQL daemon, type:

sudo /opt/local/lib/mysql5/bin/mysqld_safe &

or to make sure MySQL5 is launched at startup every time:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Create a symbolic link

sudo ln -s /opt/local/bin/mysql5 /opt/local/bin/mysql

Test the installation

mysql -u root -p

It should prompt you for a password and you should see the “mysql>” prompt

{ 2 } Comments

  1. matea | November 15, 2010 at 7:25 pm | Permalink

    thank you! excellent.

  2. Enrico | December 6, 2010 at 7:20 pm | Permalink

    didn’t work for me:

    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/opt/local/var/run/mysql5/mysqld.sock’ (2)

{ 1 } Trackback

  1. Reliably Broken » Running Django on Mac | November 19, 2010 at 7:39 pm | Permalink

    [...] commenter matea pointed to Jason Rowland’s MySQL on Mac posting that includes steps to secure a default installation, so I’ve updated this section [...]

Post a Comment

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