views:

650

answers:

6

I followed this tutorial to the very end, then found out it didn't work right. I think I have everything installed but when I type

mysql -uroot

I only get

-bash: mysql: command not found

Note: I did not skip the "Setting the Path" step. Upon running this command for the first time:

mate ~/.bash_login

This brought up an empty file. So I added this line:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

I saved the file, closed TextMate, executed the following command:

. ~/.bash_login

...and continued with the tutorial. Based on your suggestions, I thought maybe the file didn't actually get saved. So I ran the following command to bring up the file again:

mate ~/.bash_login

...yet the contents of the file were as they should be.

Any suggestions?

+5  A: 

You probably don't have the mysql binaries in your path.

The link you posted has a section on setting the path, titled "Setting the Path Do not skip this step! Most everything else will fail if you do."

EDIT: As debugging steps, try:

  • First launching a new terminal window. Does it run now?
  • Typing "echo $PATH" at the prompt. Does the path show up correctly as you've typed it in bash_profile?
  • Running it the long way: /usr/local/mysql/bin/mysql -u root Does the application run?
Jarret Hardie
You beat me by 34 seconds. +1.
Paul Tomblin
Thanks, but I did not skip that step. The file is intact. Any other suggestions for me to try?
Andrew
typing "echo $PATH", I get /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/pear/bin (no mysql in path). running the long way, I get a different issue: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Andrew
@Andrew, then you did not follow the step of the tutorial that you claim to have followed, because if you did, /usr/local/sbin and /usr/local/mysql/bin would be in your PATH.
Paul Tomblin
+1  A: 

Did you follow the step that says

Setting the Path

Do not skip this step! Most everything else will fail if you do.

Did you close your terminal window and re-open it afterwards?

Update: What does "which mysql" say? Does "ls /usr/local/mysql/bin" say?

Paul Tomblin
+1 For great minds thinking alike, 34 seconds apart ;-)
Jarret Hardie
And for the suggestion to close and re-open the terminal
Jarret Hardie
What do you mean by "The file is intact". The step was about setting your PATH. Is it set? And note, this is NOT case insensitive.
Paul Tomblin
"which mysql" returns nothing."ls /usr/local/mysql/bin" returns a bunch of stuff. mysql is one of those things in the list. is that the executable that needs to be run?
Andrew
That's proof positive that you did not set up the path. Go back and follow those instructions completely and accurately.
Paul Tomblin
+1  A: 

Another option would be to use MAMP.

It has Apache, PHP and MySQL packaged with no further setup necessary.

Mel
I've used MAMP, but I'd rather install them separately
Andrew
A: 

MySQL is usually put in /usr/local/mysql/bin/

You need to add this to your PATH, you can do this by adding the follwoing lines to your .bash_profile

PATH=$PATH:/usr/local/mysql/bin/
export PATH

The .bash_profile file is located in the root of your username directory.

Make sure you restart your Terminal for the setting to take affect.

dorzey
Yeah, that's already in the tutorial that he supposedly followed. Makes you wonder how well he followed it, doesn't it?
Paul Tomblin
The tutorial mentioned .bash_login which, at least on my Mac, is not there. Figured that could be a point of confusion.
dorzey
your approach is a little different than the tutorial, what is the difference between yours and: export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
Andrew
I'm not sure that there is a difference. I just find that having each thing you add to PATH on a separate line is more manageable; especially when you are adding several items to the PATH.
dorzey
A: 

And if you're not a command-line person, I highly recommend you also install the MySQL Preference Pane to start/stop the server and install Sequel Pro to create databases and run queries.

ftp://ftp.mysql.com/pub/mysql/download/gui-tools/MySQL.prefPane-leopardfix.zip

http://www.sequelpro.com/

Paul Lefebvre
+1  A: 

Two things:

  • Try editing ~/.profile (rather than ~/.bash_profile or ~/.bash_login).
  • You may find it easier to use the native Mac style .dmg installer directly from Sun.

One nice thing about the dmg installer is that it automagically sets up symlinks to /usr/local/mysql (which means less - or no - fiddling with your $PATH).

Telemachus
Thanks, I tried using .profile instead, but it did not work. When I run "echo $PATH" it returns "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/pear/bin." Those must be getting set somewhere, but I don't know where to look.
Andrew