It's been a while since I've had to set up a dev machine from scratch and I ran into kinda a funny issue today setting up mysql5 because I skimmed a blog post specifically regarding installing mysql5 on OSX with MacPorts, which was precisely what I wanted to do. I foolishly followed some steps and not others because I know what I'm doing... right? Maybe I do, and maybe I don't, but in this case I turned my brain off and here's what happened.
The first step is pretty obvious for even casual users of MacPorts, and nothing goes wrong here.
sudo port install mysql5 +server
After that, I get cocky -- I skipped over the section labeled Create initial MySQL databases because I'm going to create my own databases, so clearly there's no need to do that. I know, I know, anybody who has set up mysql before is probably smacking their forehead right now and thinking what a big idiot I am. Why? Because MySQL needs those initial databases for things like, ohhh, I dunno, managing who can log into MySQL, including the admin user(s). Important stuff (and I know this, but for whatever reason my neurons don't make the connection this time around).
Even worse about skipping this step: the entirety of the step is included in the output of the command above! It even explains that you've gotta do it. Did I read that output? Nooo, I know what I'm doing, I don't need to read.
From here, I skipped down to the part about setting aliases to start and stop mysql. That sounds useful, I say to myself, and so I throw a couple lines into my ~/.profile :
alias mysqlstart='sudo /opt/local/bin/mysqld_safe5 &'
alias mysqlstop='/opt/local/bin/mysqladmin5 -u root -p shutdown'
You read that right, I actually included the "amp;" in there, because it was just a copy and paste job. I didn't even think to myself, "That's just a mis-rendering of an html entity meant to represent an ampersand". Or even "ampersand at the end of a command is so that the command doesn't block the prompt". I don't know WHAT I figured that was supposed to do. I'll tell you what it does: nothing, because bash doesn't understand that either, it just spits out "amp;? seriously??"
This leads into my next problem, actually. So smugly confident was I, that I run my retarded little alias 'mysqlstart' and besides for the bash warning about amp; I get no other output.
Great, it must be running! It was not.
Strange as that was (ha), I got a bit sidetracked and ended up closing that particular terminal window. Down the line I get back to the task of figuring this out, and so I try to open a new terminal window, and lo and behold the terminal just sits there and give me no command prompt.
Disaster strikes! Obviously I must have really bungled my .profile, and so I spend a stupid amount of time figuring out how to edit that file -- which is hidden by default in Finder -- and finally figure out that TextMate's open dialog has an option to show hidden files. I had actually looked there/tried that first, but amusingly when you click on that particular checkbox TextMate does not actually refresh the contents of your current directory, and so I thought at first that the feature wasn't going to help me.
So, eventually I figure this out and open the file. I remove the amp; and restart my computer since I -still- am unable to get a command prompt from my terminal. After I restart, the command prompt is back! Wonderful. I run 'mysqlstart' again, close the terminal, and open a new terminal. SAME THING! So I reboot my machine again in order to arrive back at a command prompt, but this time I decide to run the command without the alias.
Lo and behold, what do I get? A prompt for my password! Exactly what one should expect from running SUDO. I smack my forehead, since I finally realize that while the ampersand in the alias had returned me back to the command prompt, it was still hung-up waiting for me to input the password. That's why it wasn't letting me launch new bash prompts, and that's why I was seeing no mysql output from the command.
From there all I had to do to begin to untangle this unholy mess was to use visudo to drop the following line in my sudoers file:
%wheel ALL=(ALL) NOPASSWD: /opt/local/bin/mysqld_safe5
This allows any user in the wheel group to run sudo /opt/local/bin/mysqld_safe5 without requiring a password. So eventually I reasoned my way through all the ridiculous mistakes I had made, and ended with a fully functioning mysql5.
There was a lesson here somewhere... it is not enough to follow directions; it is important to understand the directions. In my case I didn't even do a good job of blindly following directions, but if I had just thought about what I was doing I could have avoided this entire debacle. It is certainly embarrassing for me to share this cautionary tale, but it's something I hope you will be able to relate to. We all make mistakes, and they're not always flattering.
Technology keeps you humble.