explorers’ club


Getting MySQL & Mac OS X 10.5 (Leopard) together….finally
Sunday, December 9, 2007, 6:11 pm
Filed under: development, mac, mysql

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