Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to login to a MySQL database from a shell.

Normally I use

mysql -p 

But I just noticed the following in the the MySQL help:

-p, --password[=name] 
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty. WARNING: This is
                      insecure as the password is visible for anyone through
                      /proc for a short time.

Is this saying that the following is insecure?

mysql -p=mypassword

Or that all uses of -p are insecure?

share|improve this question
up vote 6 down vote accepted

Only this is insecure:

mysql -p=mypassword

because this way it can be visible when ps is used to view the command line arguments. In short, always use the -p option, and when automation is desired use an "option file"

Refer to for more information:

This is convenient but insecure, because your password becomes visible to system status programs such as ps that may be invoked by other users to display command lines. MySQL clients typically overwrite the command-line password argument with zeros during their initialization sequence. However, there is still a brief interval during which the value is visible. Also, on some systems this overwriting strategy is ineffective and the password remains visible to ps. (SystemV Unix systems and perhaps others are subject to this problem.)

share|improve this answer
Not to mention the command stays in your history for a while. – slhck Aug 30 '11 at 16:04

Your Answer


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.