Installation of MySQL server on Mac OS X Lion

This article is part of Django Installation on Mac OS X Lion

At the time of writing this post, MySQL Server on MySQL site doesn’t have installer package for OS X 10.7 (aka Lion) but 10.6 Package works just fine for 10.7 as well. This may change soon and we may see package for OS X 10.7 as well or may be rename current package to 10.6 & above.

Installing MySQL community server:

  1. Download the latest  64-Bit DMG Archive (Apple Disk Image) from MySQL Site (http://dev.mysql.com/downloads/mysql/). Current latest version is 5.5.14 which I’ll be using to install on my machine.
  2. Mount the Disk Image (I mean open/double-click the DMG file) and install MySQL server by double-clicking the PKG file (in my case mysql-5.5.14-osx10.6-x86_64.pkg) and follow onscreen instructions. ( It will ask for Master password, as it installs MySQL server in /usr/local )
  3. Add /usr/local/mysql/bin to your path by editing .profile file. (Optionally you can create alias to mysql and mysqladmin as mentioned in README File)
  4. You can start MySQL server by running “/usr/local/mysql/bin/mysqld_safe &” from terminal but Disk image you downloaded also consists of Startup Package & Preferences Pane which allows you to start/stop MySQL server from System Preferences and even Automatically Start MySQL Server at Startup.

*Please note /usr/local/mysql is only symlink to /usr/local/mysql-5.5.14-osx10.6-x86_64 which means when you upgrade to new version symlink will be changed to point to new version but won’t be deleting the older version. However you need to copy your data directory to new location to make sure your existing databases are intact post upgrade.

Installing MySQL Startup Scripts & Preferences Pane (OPTIONAL)

  1. Double Click MySQLStartupItem.pkg and Follow on screen instructions (You will be asked for Master Password)
  2. Double Click MySQL.prefPane which will add MySQL to OS X System Preferences and it should like something like below

    MySQL Mac OS X Lion Preferences

    MySQL Mac OS X Lion Preferences

  3. Check Automatically Start MySQL Server on Startup to start MySQL server at boot time.

In next section we will discuss installing phpMyAdmin which will provide us web interface to perform basic MySQL administration tasks on Mac OS X Lion.

12 thoughts on “Installation of MySQL server on Mac OS X Lion

  1. I am trying to host a WordPress site on a Lion Server. I was able to get MySQL downloaded and installed and running on this machine. However, there is a disconnect between the web server and MySQL when I try to build out a WordPress site. I have the MySQL server running and verified it is indeed running as I can hit it and make changes using Navicat. When I try to built out a WordPress site, however, I am getting the following error when it tries to create the wp-config file (I get database connection error when I try to manually create the wp-config file as well).

    “Error establishing a database connection
    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.

    Are you sure you have the correct username and password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?”

    It appears that there is a disconnect between Apache running on this machine under Lion Server and the MySQL Server that I installed. Separately they are both up and running, but for some reason they cannot communicate with each other. Can you explain what might be causing this? Any guidance is appreciated.

  2. I’m trying to get MySQL running on Lion Server. I can do it from the command line… using mysqld running as a user named mysql. I can’t for the life of me figure out how to get this to run as a daemon. The MySQL pref pain does nothing at all. No errors, no warnings.. nadda.

    I have 30 MySQL databases.. and Apple wants me to switch to PostGre… are they off their bleeding rockers?

  3. What do you mean by

    Add /usr/local/mysql/bin to your path by editing .profile file. (Optionally you can create alias to mysql and mysqladmin as mentioned in README File)

    PLEASE HELP.

  4. “Add /usr/local/mysql/bin to your path by editing .profile file. (Optionally you can create alias to mysql and mysqladmin as mentioned in README File)”

    What I did was:

    In a terminal type: nano ~/.profile

    then paste the line below:
    export PATH=/usr/local/mysql/bin:$PATH

    and save. Restart your terminal (close and open it) and do a: echo $PATH and it should not list the mysql/bin folder

  5. Do you have to be running Lion Server Edition to use mysql databases lcoally? There won’t be any remote clients. Just a loca SQL database being queried from the same machine it is stored on.

  6. Please, I don’t know where have to save .profile. I don’t find the “local” path. Can you help me with step 3 please?? Thanks!

Leave a Reply

Your email address will not be published. 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="" highlight="">