Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm just trying to do the simple task of adding my MySQL directory to the PATH variable so that I can use the mysql, etc. commands in my terminal on my Mac OS X 10.6.6 (Snow Leopard). After altering the .profile, .bash_profile, and even creating a .bashrc, and making sure that my path has been inputted correctly, every time I try running the mysql command, or hitting

echo $PATH

gives me the same exact results:

/Users/GabbAHH/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/bin:/Users/GabbAHH/.rvm/gems/ruby-1.9.2-p136@global/bin:/Users/GabbAHH/.rvm/rubies/ruby-1.9.2-p136/bin:/Users/GabbAHH/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin

As you can see, no MySQL. Later, I realize that this isn't really the problem since I removed all three of those files from my /Users/GabbAHH/ user directory, and I still get the same result!

Right now, the script inside my startup files look like this:

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

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

Was there something I've done that made my Terminal bypass these startup files? Is it just reading from the /etc/profile folder?

Does that give the same result? Regardless, I've interchanged them.

Also, how do I tell if I'm using an interactive or non-interactive shell, and a log-in/non log-in shell? I seem to be able to create folders, etc. without a prompt to input my password, although I remember prior I had to sudo a lot of commands when installing gems for Ruby, etc. Also, I did need to input my password when turning MySQL on/off.

share|improve this question
    
does it work outside the startup script? –  Orbit Mar 3 '11 at 6:58
    
@writ Instead of yelling Thank you very much a better option would be to accept his answer by clicking on the green checkmark beside his answer, to indicate that he's solution helped you solve your problem ;) –  Yi Jiang Mar 4 '11 at 12:09
add comment

migrated from stackoverflow.com Mar 4 '11 at 15:40

This question came from our site for professional and enthusiast programmers.

2 Answers

Just put:

echo HELLO, I AM HERE

in your startup script and login as per normal.

If you find that the string is not printing out then, yes, you're bypassing that script.

Beyond that, you should tell us which script you're putting it in since bash has some ... rather wondrous ... rules for deciding which scripts get run :-) You can get the details from the INVOCATION section of man bash. My particular version goes on for about 50 lines (and that's with a 150-column xterm) so I won't bore you by posting it here.

Suffice to say it's complicated.

For example, you may be being bitten by the fact that bash will only execute the first of ~/.bash_profile, ~/.bash_login, and ~/.profile that exists and is readable. It may be a non-interactive shell where the rules are different. You may be running the shell with --noprofile or --norc or --rcfile=whatever or --posix.

The possibilities, while not endless, are damnably annoying.

share|improve this answer
    
Thank you for your response! When I open terminal (no log-in) I do get "HELLO, I AM HERE" printed when I enter "echo HELLO, I AM HERE". So, does this mean that the script to use the startup files is not being bypassed? Again, I don't think my Terminal is reading those 3 aforementioned startup files at all, since I got the same result in echo $PATH when I removed them completely from my home user holder. I'm not sure what you mean by the invocation section. I entered "man bash" which first printed out rows of blank lines, and then some descriptions that does not include invocation –  writ Mar 3 '11 at 21:26
    
If you put that echo in the startup file and the terminal printed it out when it started, then it is being processed. In the script where you add mysql to the path, precede that with echo XYZZY and put echo $PATH after it. –  paxdiablo Mar 3 '11 at 23:24
    
Thank you paxdiablo for your quick response. I didn't even do what you last told me to, but I simply one by one removed the HELLO, I AM HERE script from my startup script files and narrowed it down to the .bash_profile that is being read from. The good news is, after removing them all completely, my MySQL commands work now! But what's troublesome is that I have no idea why it works now since I have the same exact script as before. I haven't even restarted my computer. I've just entered the echo XYZZY and echo $PATH into .bash_profile and I get –  writ Mar 4 '11 at 2:22
    
XYZZY /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin Typing in echo $PATH still elicits the same thing as before. This means I still don't see the MySQL directory listed anywhere! This is my .bash_profile currently: echo XYZZY echo $PATH export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.export What's even more disturbing is that I can't seem to reproduce the same results as removing your two lines, i got the same.... –  writ Mar 4 '11 at 2:28
    
bash: command not found error again when typing a MySQL command, but later, when I readd, resave, remove, resave, it works all over again! It seems to have a mind of it's own, at the expense of my mind! –  writ Mar 4 '11 at 2:29
add comment

My issue was the existence of a .bash_profile, so I made my changes by modifying there. All it was doing before was setting up my JAVA_HOME and a GROOVY_HOME...so I added my changes to the end of that file and now all is working great.

Thanks!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.