How to Install MySQL on Mac OS X

The process to install MySQL on Mac OS X is a pretty straight forward process. MySQL is one of the most popular open source databases. It is used in a wide variety of applications.

Download MySQL Installer

First you will need to download the DMG archive from http://dev.mysql.com/downloads/mysql/

Install MySQL from the downloaded DMG archive as you would normally a typical application.

Additional Configuration

For maximum compatibility you should create a symbolic link to where MySQL places the socket. This will help other applications that assume where the socket is located.

In the terminal:

sudo su -
cd /var
mkdir mysql
cd mysql
ln -s /tmp/mysql.sock mysql.sock

To make it easier to run MySQL commands from the terminal, you will should update your bash profile. This assumes that your .bash_profile does not exist. If it does, you should probably manually edit the file and add the appropriate part below. In the terminal:

echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile

Start MySQL Server

Start MySQL server from the new MySQL icon in your system preferences.

After starting the MySQL server you will want to complete your configuration by running the secure installation script from the terminal by issuing the mysql_secure_installation command. When prompted you should set a password and accept the default of Yes for all other options.

Take MySQL Further

To learn more about MySQL I suggest you pick up a copy of High Performance MySQL: Optimization, Backups, and Replication. Optionally you may want to install a visual MySQL client so you don’t have to do everything in the terminal. I would recommend installing the Sequel Pro client for Mac OS X.

I hope this guide has given you enough enough information to install MySQL on Mac OS X. It is a really simple process.

3 thoughts on “How to Install MySQL on Mac OS X

  1. Ajay

    You need to becareful with this line

    echo ‘export PATH=”/usr/local/mysql/bin:$PATH”‘ > ~/.bash_profile

    it should be–
    echo ‘export PATH=”/usr/local/mysql/bin:$PATH”‘ >> ~/.bash_profile

    or you should back it up first

    Like

  2. Saroj

    Thank you for these instructions. After over 20 years of working with windows, I moved to macbook recently. Appreciate the clarity of instructions. My mysql installation worked without a problem.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.