[UPDATE 2010.11.26]
There MAY be a 10.6 installer for MySQL. Before engaging in this tutorial, please do proper research to see if there are easier and more direct ways of installing MySQL for Snow Leopard.
[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).
note – if you are using Snow Leopard, Directory Utility is located at /System/Library/CoreServices, please note that I updated just this portion on the post and have not tested this any further with Snow Leopard to attempt to clarify some comments below. - 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/mysql
This 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 root
This 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-stop
You 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.
Wednesday, December 19, 2007 at 4:58 pm
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.
Wednesday, December 19, 2007 at 5:03 pm
I 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,
J
Wednesday, January 2, 2008 at 11:38 pm
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
Wednesday, January 16, 2008 at 4:39 pm
You 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
Monday, April 25, 2011 at 4:53 pm
I wonder if you have a solution on installing libmycrpt on mac port?
phpmyadmin complains that it is not installed.
Wednesday, April 27, 2011 at 6:52 pm
I do not sorry. It’s been so long since I have even messed with PHP or MySQL on my mac.
Sunday, March 2, 2008 at 6:01 pm
great tip, mysql is now working perfectly…
thanks!
Furio
Friday, March 7, 2008 at 12:31 am
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.
Friday, March 7, 2008 at 12:33 am
I 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.
Sunday, March 16, 2008 at 2:49 pm
Thank you thank you thank you!
I 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!
Monday, March 17, 2008 at 6:07 pm
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.
Tuesday, March 25, 2008 at 7:15 pm
mysql 5.0.45 would not start under leopard 10.5.2
this would fix it!!
# sudo chown _mysql /var/mysql
tnx
Wednesday, March 26, 2008 at 10:59 am
[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
tmpdir=/usr/local/mysql/tmp
Tuesday, April 1, 2008 at 11:00 am
Thank you so much!!!!
Friday, April 4, 2008 at 4:27 am
shit! now nothings of mysql works after following your instructions.
Monday, April 7, 2008 at 7:46 pm
sorry, 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
Monday, April 7, 2008 at 8:11 pm
in 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)”
Monday, April 7, 2008 at 8:16 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.
Tuesday, October 26, 2010 at 5:37 pm
The reason he is confused is because in the instructions you say “Directory Utility” not “Disk Utility” this confused me for a few seconds too. There is no “Directory Utility”
p.s. ‘cmd-shft-U’ =>Awesome!
Tuesday, October 26, 2010 at 5:47 pm
Try that again….ignore my above. IT IS NOT the “Disk Utility”
In Mac OS X 10.6 (Snow Leopard) the directory utility is in:
/System/Library/CoreServices/Directory Utility.app
you can access through System Preferences / Accounts
or through the terminal with:
open /System/Library/CoreServices/Directory\ Utility.app/
Friday, April 11, 2008 at 8:30 am
Great 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,
Phil.
Friday, April 11, 2008 at 2:54 pm
@Guilfie
Thanks for the input. #1 should be fixed now and as for #2, that is some of the best news I have heard all day.
Friday, April 11, 2008 at 4:00 pm
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,
Dipesh.
Monday, April 14, 2008 at 3:55 pm
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.
Wednesday, April 16, 2008 at 8:33 pm
Minor 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
Wednesday, April 16, 2008 at 9:28 pm
Interestingly 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.
Wednesday, April 16, 2008 at 10:40 pm
Re 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
Saturday, April 19, 2008 at 12:20 am
Great Article!! thank you for your time.
this is my first mac after 10 years of pc… you really helped me, I added you to my favorites.
Sunday, April 20, 2008 at 2:14 pm
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.
Sunday, April 20, 2008 at 2:52 pm
Hey 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.
Monday, April 28, 2008 at 1:38 pm
I 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!
Tuesday, July 1, 2008 at 6:51 pm
great post dude..thanks!!
Tuesday, July 8, 2008 at 4:49 am
Thanks for the post. You have removed one of the splinters in mind!
Wednesday, July 16, 2008 at 2:58 pm
After 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!
Wednesday, July 16, 2008 at 3:29 pm
Hi 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.
Friday, July 18, 2008 at 5:38 pm
As 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!
Friday, July 18, 2008 at 6:59 pm
A 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
Friday, July 18, 2008 at 7:20 pm
Correct. 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.
Pingback: Start/Stop MySQL from a terminal session on OS X : Dan’s Drivelings
Sunday, August 10, 2008 at 12:04 pm
THANK YOU SO MUCH. I wish there were more easy to follow guides like this one. You’re a lifesaver.
Thursday, September 25, 2008 at 8:59 pm
THANK YOU SO MUCH FOR THIS, I COULDN’T FIND THE HELP I NEEDED ANYWHERE ELSE, THANKS SO MUCH FOR THIS MAN!
Friday, November 14, 2008 at 2:53 am
u>>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
Thank you Sir and pliz keep that gud work going.
Pingback: Installing PHP with GD Library & MySQL on Mac OS X Leopard 10.5x at Here & there…
Wednesday, February 25, 2009 at 8:05 pm
Yes, 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
Tuesday, March 8, 2011 at 3:44 am
help ….
how to make inventory system in macromedia dreamweaver connected to xampp???
please help me……
Wednesday, March 25, 2009 at 4:45 am
I 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!
And thanks for the article – tip top!
Pingback: vansw’s blog » mysql
Thursday, May 28, 2009 at 6:40 am
You 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.
Thursday, June 4, 2009 at 12:13 am
considering 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.
Wednesday, June 17, 2009 at 1:50 am
Getting this error:
1)
mysql-start
Starting MySQL
… ERROR! Manager of pid-file quit without updating file.
2)
mysql -u root
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
Tuesday, August 18, 2009 at 5:22 pm
Thanks for the instructions, they helped me get up and running. I didn’t run into nearly as many problems though. I put together a short article on the steps I took too. Hopefully it can also be of service to someone! http://obscuredclarity.blogspot.com/2009/08/install-mysql-on-mac-os-x.html
Pingback: Installing MySQL on OS X 10.5 Leopard « Surfsoft Consulting Blog
Monday, October 26, 2009 at 4:48 am
Here’s a MAMP workflow which includes Dreamweaver and other SQL GUI tools for developing PHP/MySQL on Snow Leopard:
http://totalnoob.wordpress.com/2009/10/25/beginners-guide-to-developing-php-and-mysql-sites-on-a-mac/
Wednesday, March 10, 2010 at 9:55 pm
Thanks a ton – this was so helpful!!
Tried for HOURS to get this working, and no other post I found could get mysql running on my mac. Really frustrating, so glad to have found such easy to follow instructions 🙂
Sunday, April 4, 2010 at 5:58 pm
Like so many others who have commented here, I wasted too many hours trying to get this to work, and yours is the first page that I have found that actually helps.
One thing I would add is that I was still having problems at step 7… this was the result of having tried so many other methods to get this installed. The cleanup step you provided is a good start, but it turns out I had to go further to get all of my abortive attemps cleaned up (including macports). Once I found and removed *every* mysql installation attempt, restarted, reassured myself that there were no mysql-related processes running (by running ps -ef | grep mysql) then ran mysql-start, I finally got that longed-for SUCCESS message.
Thank you very, very much!
Saturday, October 16, 2010 at 8:23 am
Hi jwopitz,
quite an old blog and still very helpful. I just spent half a night with not succeeeding in installing mysql… until I found your blg. THANKS!
Felix
Saturday, October 23, 2010 at 5:06 pm
Gr8 Article, I had almost given up, then fond this one, way to go!! thanks !!
Thursday, December 9, 2010 at 10:19 pm
THANK YOU SO MUCH! Why is using mysql on a macbook so different from using it on any other system?? So dumb! But this article was VERY helpful.
Thanks again 🙂
Tuesday, March 8, 2011 at 3:53 am
ewwwwwwwwwwwwwwwwww
Sunday, May 15, 2011 at 2:30 pm
Thank you so much. I was struggling with this for some time. Success!
Tuesday, January 8, 2013 at 2:50 pm
Fine way of explaining, and fastidious post to take
data on the topic of my presentation subject matter,
which i am going to deliver in academy.