Many command line programs, such as mySQL and Apple's Xgrid, are not OS X Keychain savvy, and require passwords in plaintext on the command line. This can also be true when entering things like SMB and AFP disk mounts from the command line. Command line text will not only appear in plain view on your screen and terminal scroll-back but it persists indefinitely in your bash history file on disk. It can even sometimes be viewed in process monitors that show your executing commands to other users. Here is a way to avoid that pitfall.
A common approach is to put the passwords in environment variables the commands will access. For example, Xgrid will access the environment variable XGRID_CONTROLLER_PASSWORD if it is defined. However this does not solve the problem of how you get the password into the environment variable. Using the command line obviously is out. You can put it in your .profile or .bashrc in plain text, but this is again persistent on disk and your Time Machine backups and those are exposed to any program you run and to admin users.
I found a versatile solution in the OSX xgrid users wiki atTenGrid.com which suggests the following code:
`perl -we 'eval {system("stty -echo");$x=<>}; system("stty echo"); print "export XGRID_CONTROLLER_PASSWORD=$x"'`
When you run that from the command line, it lets you type in the password invisibly and then it puts it in the shell's environment for you. It's only accessible from within that shell, so other programs can't see it. When you eventually close that shell all traces of it vanish and at no time is it stored (directly at least) in plain text on disk. Of course, anyone with keyboard access to that terminal could probe your environment variables, but if that is true, this may be the least of your problems.
You can automate this command by setting up an alias in the .bashrc or .profile like this (keep the escaped characters!)
alias xgpwd=\`perl\ \-we\ \'eval\ \{system\(\"stty\ \-echo\"\)\;\$x\=\<\>\}\;\ system\(\"stty\ echo\"\)\;\ \ print\ \"export\ XGRID_CONTROLLER_PASSWORD\=\$x\"\'\`Mac OS X Hints
http://hints.macworld.com/article.php?story=20100702095749620