[UPDATE]
It appears that a 10.5 friendly version of mysql has been released. Before engaging in this tutorial you might want to check with a more traditional install procedure that comes with the newest version of mysql.
======================
Firstly, I should preface this post by saying that there are probably at least a dozen posts on this topic. All are basically the same with little differences here and there. None of them worked for me. But what did work (so far) is taking bits and pieces from a post here and a post there to finally get something working. Thanks goes out to all those other bloggers who provided the information found here.
Additionally, if things keep going the way they had been, this might not work at all. I have had MySQL up and running several times only to return to find it no longer wants to start for me.
Keep in mind that this is my attempt at a new install of MySQL on my newly acquired MacBook Pro (MBP hereinafter).
Step 1: Enable your root user
- Open the Directory Utility: In the Finder, navigate to the Utilities folder (tip: click on the desktop, hit Cmd+Shift+U).
- Click on the padlock to allow edits.
- Go Edit > Enable Root User
- Enter and re-enter your password.
Now, you are set to access protected areas of the system via the terminal.
[Excerpt from StringFoo's post]
Step 2: Backup any existing databases from previous versions of MySQL
I never had anything installed so I never attempted to do so. But this goes without saying for you other folks.
Step 3: Remove previous versions of MySQL
I did attempt multiple installs so I did remove them prior to my finally working install. I had nothing to preserve so again, if you are looking to backup a previous version you might want to research it.
- Open a new Terminal window.
- Remove the installed location by typing
sudo rm -rf /usr/local/mysql(keep in mind that if you backed up your databases in this directory it is targeted to get deleted!!!). What this basically says (for all of we new Mac users is: super user remove the targeted folder and recursively do so to any subsequent folders and files from this location. - Remove any launchers by typing
sudo rm -rf /Library/StartupItems/MySQLCOM/
[Excerpt from Hivelogic's post]
Step 4: Add environment variables and some Terminal alias to launch MySQL
- Open a Terminal window.
- Use a command-line text editor to create the enviro-vars and aliases by typing
pico ~/.bash_login(that is a tilde not a dash btw). This opens the pico text editor and either opens or creates the .bash_login hidden file at your user’s folder. - Add the following text:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
alias mysql-start="sudo /usr/local/mysql/support-files/mysql.server start"
alias mysql-stop="sudo /usr/local/mysql/support-files/mysql.server stop" - type ctrl-x to initiate closing Pico.
- type y to save it.
- type enter to save to the prompted location
- You should now be back in Bash
- Now get Teminal to load those new aliases and path type:
. ~/.bash_login
Step 5: Grab the MySQL installer and install
- Grab the appropriate installer from the MySQL download page (I am using the intel based MBP)
- Install to the default locations.
- I went ahead and installed the System Preferences utility that is supposed to help you start/stop MySQL’s server, however it did not work. Do so if you wish and maybe you can get it to work. Here are some comments on how you might get it going
Step 6: Update ownership of some launch-specific files
- In a terminal window, type the following in order to create a folder where the MySQL sock file will live.
- Create the folder:
sudo mkdir /var/mysqlThis just says super user make directory mysql in the var directory - Change ownership of that directory to the user _mysql:
sudo chown _mysql /var/mysql
[Excerpt from StringFoo's post]
Step 7: Start the MySQL server and then login
Hopefully, if I remember all the steps I took to get this working and it actually works for you, then you should be able start the MySQL server and login.
- Type
mysql-start - If all is well you should see a succsss message. So now login by typing:
mysql -u rootThis just means login to the MySQL server as the user root - If that works then you should see a prompt saying
mysql> - If you want to stop the MySQL server, exit the current user by typing:
exit - You should now be back in the terminal so type:
mysql-stopYou should then see another Success message saying that you stopped the server
That’s it. Again, I should really thank the community out there for providing various approaches to getting this thing up and running on Leopard. If you are like me, a new Mac user, then hopefully this will get you working with MySQL. Keep checking the web for a Leopard supported installer so then we can make use of the System Preferences MySQL launcher.
45 Comments so far
Leave a comment
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Good article.
Will be useful when I buy my macbook.
Did you try xampp?
I use it on Windows and it makes everything a little easier. The mac version is only in beta though.
Comment by Ed Wednesday, December 19, 2007 @ 4:58 pmI have not. I did start using MAMP and it is a breeze. I am currently using it with AMFPHP and considering using CAKE PHP on it as well.
I will check into xampp sometime. Thanks,
Comment by jwopitz Wednesday, December 19, 2007 @ 5:03 pmJ
A great article.
N.B. If you get “mysql> No such process ERROR! (9384)” at step 7 – I recommend a restart after step 6.
Worked for me, thanx J
Rob
Comment by Rob Morgan Wednesday, January 2, 2008 @ 11:38 pmYou should install macports:
http://www.macports.org/
Once installed, getting mysql (and a whole host of other apps) is as easy as:
$ sudo port install mysql5
-Chris
Comment by chris Wednesday, January 16, 2008 @ 4:39 pmgreat tip, mysql is now working perfectly…
Comment by furio Sunday, March 2, 2008 @ 6:01 pmthanks!
Furio
I have mysql installed and I get the following errors
:mysql myc$ touch: /usr/local/mysql/data/mycomputer-power-mac-g4.local.err: Permission denied
chown: /usr/local/mysql/data/mycomputer-power-mac-g4.local.err: Permission denied
Starting mysqld daemon with databases from /usr/local/mysql/data
./bin/mysqld_safe: line 380: /usr/local/mysql/data/mycomputer-power-mac-g4.local.err: Permission denied
rm: /tmp/mysql.sock: Permission denied
rm: /usr/local/mysql/data/mycomputer-power-mac-g4.local.pid: Permission denied
./bin/mysqld_safe: line 386: /usr/local/mysql/data/mycomputer-power-mac-g4.local.err: Permission denied
STOPPING server from pid file /usr/local/mysql/data/mycomputer-power-mac-g4.local.pid
tee: /usr/local/mysql/data/mycomputer-power-mac-g4.local.err: Permission denied
080306 16:15:29 mysqld ended
tee: /usr/local/mysql/data/mycomputer-power-mac-g4.local.err: Permission denied
I am a CS student with only a semester of junior college CS under my belt so easy to understand answers are appreciated. Thanks.
Comment by ashii Friday, March 7, 2008 @ 12:31 amI have actually switched to using MAMP for most of my MySQL needs. If you are a CS student and are doing some basic MySQL tutorials for your classes, you should check it out. Its free and it comes with a simple GUI to write your queries in. I love using it.
Comment by jwopitz Friday, March 7, 2008 @ 12:33 amThank you thank you thank you!
Comment by SJ Sunday, March 16, 2008 @ 2:49 pmI have tried many MANY attempts to install mysql and have always failed somewhere along the line.
This worked and now I can get on with the (hopefully less painful) process of building my database.
Bless the internet and bless you!
It took me forever to figure out how to get this to work, and yet when I was ready to give it up I found this page
I went through the same webpages you cited here to try and figure it out, but since im new to macs, piecing it together was too hard.
Thanks a million for putting together a quick and easy and (most importantly) corrct way of getting MySQL up and running on Leopard.
Comment by jgildart Monday, March 17, 2008 @ 6:07 pmmysql 5.0.45 would not start under leopard 10.5.2
this would fix it!!
# sudo chown _mysql /var/mysql
tnx
Comment by pepijn Tuesday, March 25, 2008 @ 7:15 pm[quote]
Many people have been reporting issues with MySQL under Leopard with this error:
mysqld: Can’t create/write to file ‘/var/folders/2F/2FtguLeuG1ibx1X9tbDS0E+++TI/-Tmp-/ibYWBjEU’ (Errcode: 13)
071204 11:15:48 InnoDB: Error: unable to create temporary file; errno: 13
I have discovered a fix for this particular issue. First, in the Terminal, go into your MySQL root directory (mine is /usr/local/mysql). Then type these commands:
sudo mkdir tmp
sudo chown _mysql:wheel tmp
sudo chmod 755 tmp
This will create a temporary directory that MySQL will use. Now we have to make sure MySQL knows about this new location for temporary information, so open up your my.cnf and add this line:
tmpdir=/usr/local/mysql/tmp
(Where the path after the equals sign is the path to your tmp directory).
After this, restart MySQL and all should run fine.
[/quote]
also copy the config file :
# cp support-files/my-medium.cnf /etc/my.cnf
and copy this line to it
Comment by pepijn Wednesday, March 26, 2008 @ 10:59 amtmpdir=/usr/local/mysql/tmp
Thank you so much!!!!
Comment by Hamish Tuesday, April 1, 2008 @ 11:00 amshit! now nothings of mysql works after following your instructions.
Comment by steven Friday, April 4, 2008 @ 4:27 amsorry, I’m a new Mac user (got the OS X 10.5) and I’m stuck to the first step.
# Click on the padlock to allow edits.
# Go Edit > Enable Root Password
# Enter and re-enter your password.
what’s the padlock ? Is it the Edit of the Finder ? Don’t find the “Enable Root Password” ? Have nothing on my keyboard ? I feel stupid…
padlock is it something download ?
Thanks for your time
Comment by Damien Monday, April 7, 2008 @ 7:46 pmin fact, I try to reinstall MySQL an other way because phpMyAdmin didn’t work and I got an error msg when I launch its setup.php after configuring the config.inc.php:
“#2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)”
Comment by Damien Monday, April 7, 2008 @ 8:11 pm@Damien
Regarding the padlock, you should see an icon in the lower left corner of the Disk Utility. If you are not seeing that, then you may not be in the right application to do this. As for the other issues, this may be caused by the fact that you did not have access to the root password.
If you are new to Mac and PHP is an option, then check out MAMP. It takes alot of the headaches out of this setup bs.
Comment by jwopitz Monday, April 7, 2008 @ 8:16 pmGreat post, two minor points for you.
1. In step 1 the Edit menu item is actually “Enable Root User”, not “Enable Root Password”
2. As of today (when I downloaded MySQL) there is an OSX 10.5 release (5.0.51a) that includes the startup item, which is installed and working on my MacBook Pro.
Thanks,
Comment by Gulfie Friday, April 11, 2008 @ 8:30 amPhil.
@Guilfie
Comment by jwopitz Friday, April 11, 2008 @ 2:54 pmThanks for the input. #1 should be fixed now and as for #2, that is some of the best news I have heard all day.
I’m glad I stumbled on this page. Last night, I tried installing mySql, ver. 10.5 (5.0.51a (x86), on my MacBook Pro (unsuccessfully).
Prior to installing, I enabled php as per http://mymacinations.com/2007/10/28/apache-php-and-mysql-on-leopard/. I then followed the advise about creating a php.ini copy and setting:
mysql.default_socket = /private/tmp/mysql.sock
mysqli.default_socket = /private/tmp/mysql.sock
Next, I installed mySql, however, I cannot seem to start mySql or set the password (as per the post no. 7 on http://mymacinations.com/2007/10/28/apache-php-and-mysql-on-leopard/) as follows:
/usr/local/mysql/bin/mysqladmin -u root password
Can anyone help a poor sap like me out? Also, what directory is mySql installed to?
Thanks so much in advance!
Cheers,
Comment by Dipesh Friday, April 11, 2008 @ 4:00 pmDipesh.
Thank you a lot for this tutorial. I get it running thanks to you. I don’t know why the MySQL installer does not work. Thanks.
Comment by Txinto Monday, April 14, 2008 @ 3:55 pmMinor confession, item 2 in my previous post – you have to copy the incorrectly located startup files as follows:
sudo cp -R /usr/local/MySQLCOM/ /Library/StartupItems/MySQLCOM
Comment by Gulfie Wednesday, April 16, 2008 @ 8:33 pmInterestingly enough having installed successfully on my MacBook Pro using these instructions, I also get the “bad CPU Type in executable” message that Dipesh alludes to when I repeated the installation on one of my two Mac Minis.
This also runs OSX 10.5.2 Leopard, is patched to the same level as the laptop, and I’ve even re-used the same MySQL download… I will post more here if I am able to find a solution.
Comment by Gulfie Wednesday, April 16, 2008 @ 9:28 pmRe the Bad CPU Type… OK guys here is the answer. Apple have put different Intel processors in their machines and they aren’t compatible at the binary level. So at the mysql site you need a different download depending on your CPU type. To check what you have, go to the Apple menu and click on ‘about this mac’. The processor type will be Intel Core 2 Duo or Intel Core Duo (or PowerPC
.
If your processor is an Intel Core 2 Duo, download an x86_64 distribution. All the current machines I’ve checked on the Apple web site – MacBook, MacBook Pro, Mac Mini, are all states as being Core 2 Duo. However my 9 month old Mac Mini (bought August 07) is a Core Duo, whereas my second Mac Mini (bought December 07) is a Core 2 Duo… this is a pain for me because I won’t be able to use time machine to image one Mac Mini from the other…
I realised what was going on after I read this post on the mysql site: http://forums.mysql.com/read.php?11,167056,202714#msg-202714
Comment by Gulfie Wednesday, April 16, 2008 @ 10:40 pmGreat Article!! thank you for your time.
Comment by Barry Saturday, April 19, 2008 @ 12:20 amthis is my first mac after 10 years of pc… you really helped me, I added you to my favorites.
Nice article Wopitz!
Who would have thought I would traverse the internet to find the ONLY article that makes MySQL work on Leopard written by a guy I could have just called in the first place…
Thanks bro.
Comment by Thomas Holland Sunday, April 20, 2008 @ 2:14 pmHey Burke!!! Glad to be of service. Wow. Its weird how you stumbled upon this. You know you can call me anytime. Hope all is well.
Comment by jwopitz Sunday, April 20, 2008 @ 2:52 pmI had managed to install and run mysql, then a week later and I rebooted and it was no longer running… your article helped with the .bash_login file and setting the env vars, I had not used a unix since ‘95 so had forgotten what the file was called (I had made an attempt with .bashrc)
Many thanks!
Comment by Mike Monday, April 28, 2008 @ 1:38 pmgreat post dude..thanks!!
Comment by Apoorv Tuesday, July 1, 2008 @ 6:51 pmThanks for the post. You have removed one of the splinters in mind!
Comment by scsimofo Tuesday, July 8, 2008 @ 4:49 amAfter reading all of the comments on this post i am excited to see the very high success rate. All of my other attempts to get MySQL up and running have been unsuccessful, maybe this will work.
At this point I am STUCK ON STEP #1: Enable Root User. I open the Directory Utility, then click the pad lock, (it prompts me for my user password) i enter my password, then i select Enable Root User from the edit menu expecting to be prompted for a password but nothing happens.
Does this mean I don’t have to enter a password?
Do i need to be logged in to Leopard as the root user to do this?
Thanks to anyone who can help!
Comment by jonboy Wednesday, July 16, 2008 @ 2:58 pmHi Jonboy.
Its been awhile since I have done this but I think by virtue of entering your password to enable changes to the Directory Utility, you have successfully enabled the root user. I would do a search to see if you can test for an enabled root user.
Sorry I am not much more help on this.
Comment by jwopitz Wednesday, July 16, 2008 @ 3:29 pmAs it turns out my my root user was not enabled. In order to solve the problem i had to:
1. log out from my admin user account
2. log in as the root user
3. change the root user account password (System Preferences -> Accounts -> Change Password)so it was blank
4. then log back in using my admin user account.
Once i had completed these steps i was able to proceed with the above tutorial.
Thanks!
Comment by jonboy Friday, July 18, 2008 @ 5:38 pmA final note: In step four, when modifying the .bash_login file, it says to type:
. -/.bash_login
for me it would only work when i used a tilda instead of a dash i.e.
. ~/.bash_login
Comment by jonboy Friday, July 18, 2008 @ 6:59 pmCorrect. That should be a tilde not a dash. This particular font size for the article makes it hard to distinguish the two. I will put a note up there tho for future reference. Thanks for the input.
Comment by jwopitz Friday, July 18, 2008 @ 7:20 pm[...] thanks to this blog post on the “explorer’s club” blog (specifically steps 3.3 and 4.3) for getting me on [...]
Pingback by Start/Stop MySQL from a terminal session on OS X : Dan’s Drivelings Wednesday, July 30, 2008 @ 3:01 amTHANK YOU SO MUCH. I wish there were more easy to follow guides like this one. You’re a lifesaver.
Comment by Renee Sunday, August 10, 2008 @ 12:04 pmTHANK YOU SO MUCH FOR THIS, I COULDN’T FIND THE HELP I NEEDED ANYWHERE ELSE, THANKS SO MUCH FOR THIS MAN!
Comment by fodnod Thursday, September 25, 2008 @ 8:59 pmu>>u God Bless u~ for who u are coz not so many pple wud take time out to publish this kind of info and even of all make it so clear and gud like you did
Comment by wallace karee Friday, November 14, 2008 @ 2:53 amThank you Sir and pliz keep that gud work going.
[...] 2. Installing and compiling MySQL http://jwopitz.wordpress.com/2007/12/09/getting-mysql-mac-os-x-105-leopard-togetherfinally/ [...]
Pingback by Installing PHP with GD Library & MySQL on Mac OS X Leopard 10.5x at Here & there… Saturday, January 31, 2009 @ 1:46 pmYes, yes, yes. I’ve been trying to learn Ruby on Rails and have not been able to figure out this mysql part until now. Success!
Thanks very much for this great help.
Jeff
Comment by Jeff Hendrickson Wednesday, February 25, 2009 @ 8:05 pmI found that when I went to run .bash_login I got ‘Permission Denied’ A bit of poking around found that I didn’t have the right permissions.
Running:
chmod 755 ~/.bash_login
Sorted this out. Phew!
Comment by Rob Wednesday, March 25, 2009 @ 4:45 amAnd thanks for the article – tip top!
[...] http://jwopitz.wordpress.com/2007/12/09/getting-mysql-mac-os-x-105-leopard-togetherfinally/ [...]
Pingback by vansw’s blog » mysql Thursday, April 23, 2009 @ 12:20 amYou can actually use sudo instead of activating the root user. I noticed some people got hung up on that. I personally just do not want to activate root.
Comment by ZMT Thursday, May 28, 2009 @ 6:40 amconsidering how much you might be able to screw up using the root, (not that you can’t do that using sudo) this isn’t a bad idea.
Comment by jwopitz Thursday, June 4, 2009 @ 12:13 amGetting this error:
1)
mysql-start
Starting MySQL
… ERROR! Manager of pid-file quit without updating file.
2)
Comment by dan Wednesday, June 17, 2009 @ 1:50 ammysql -u root
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)