explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

Getting MySQL & Mac OS X 10.5 (Leopard) together….finally

61 Comments

[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

  1. 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.
  2. Click on the padlock to allow edits.
  3. Go Edit > Enable Root User
  4. 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.

  1. Open a new Terminal window.
  2. 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.
  3. 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

  1. Open a Terminal window.
  2. 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.
  3. 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"

  4. type ctrl-x to initiate closing Pico.
  5. type y to save it.
  6. type enter to save to the prompted location
  7. You should now be back in Bash
  8. Now get Teminal to load those new aliases and path type: . ~/.bash_login

Step 5: Grab the MySQL installer and install

  1. Grab the appropriate installer from the MySQL download page (I am using the intel based MBP)
  2. Install to the default locations.
  3. 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

  1. In a terminal window, type the following in order to create a folder where the MySQL sock file will live.
  2. Create the folder: sudo mkdir /var/mysql This just says super user make directory mysql in the var directory
  3. 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.

  1. Type mysql-start
  2. 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
  3. If that works then you should see a prompt saying mysql>
  4. If you want to stop the MySQL server, exit the current user by typing: exit
  5. 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.

About these ads

61 thoughts on “Getting MySQL & Mac OS X 10.5 (Leopard) together….finally

  1. 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.

  2. 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

  3. 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

  4. 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

  5. great tip, mysql is now working perfectly…
    thanks!
    Furio

  6. 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.

  7. 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.

  8. 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!

  9. 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.

  10. mysql 5.0.45 would not start under leopard 10.5.2

    this would fix it!!

    # sudo chown _mysql /var/mysql

    tnx

  11. [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

  12. Thank you so much!!!!

  13. shit! now nothings of mysql works after following your instructions.

  14. 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

  15. 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)”

  16. @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.

    • 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!

      • 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/

  17. 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.

  18. @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.

  19. 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.

  20. 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.

  21. 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

  22. 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.

  23. 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

  24. 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.

  25. 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.

  26. 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.

  27. 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!

  28. great post dude..thanks!!

  29. Thanks for the post. You have removed one of the splinters in mind!

  30. 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!

  31. 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.

  32. 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!

  33. 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

  34. 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.

  35. Pingback: Start/Stop MySQL from a terminal session on OS X : Dan’s Drivelings

  36. THANK YOU SO MUCH. I wish there were more easy to follow guides like this one. You’re a lifesaver.

  37. THANK YOU SO MUCH FOR THIS, I COULDN’T FIND THE HELP I NEEDED ANYWHERE ELSE, THANKS SO MUCH FOR THIS MAN!

  38. 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.

  39. Pingback: Installing PHP with GD Library & MySQL on Mac OS X Leopard 10.5x at Here & there…

  40. 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

  41. 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!

  42. Pingback: vansw’s blog » mysql

  43. 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.

  44. 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)

  45. 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

  46. Pingback: Installing MySQL on OS X 10.5 Leopard « Surfsoft Consulting Blog

  47. 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/

  48. 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 :)

  49. 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!

  50. 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

  51. Gr8 Article, I had almost given up, then fond this one, way to go!! thanks !!

  52. 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 :)

  53. Thank you so much. I was struggling with this for some time. Success!

  54. 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.

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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.