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:
- 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.
- 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 )
- 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)
- 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)
- Double Click MySQLStartupItem.pkg and Follow on screen instructions (You will be asked for Master Password)
- Double Click MySQL.prefPane which will add MySQL to OS X System Preferences and it should like something like below
- 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.

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.
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?
Your port helped so much! Now i can run localhost phpmyadmin thanks to you !
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.
“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
The pref pane does not work for me. Does it work for you?
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.
Excellent post! Thank you. MySQL backup and running.
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!
Thanks for sharing, MySQL up and running on brand new macbook pro
Thanks for the help,
This page will explain how to install mySQL as a deamon at startup
http://blog.mclaughlinsoftware.com/2011/02/10/mac-os-x-mysql-install/
Wow! I am so grateful for this post! Another satisfied “customer”!!!