Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 use the mysql command line client frequently. Sometimes I wind up typing in my password dozens of times per day, and I'm getting really tired of it.

SSH has a neat utility called ssh-agent which lets you type in your password just once at the beginning of the day. Is there a similar utility for MySQL?

share|improve this question
up vote 4 down vote accepted

No. However, you can store your password in a my.cnf file in your home directory. For example, on linux

$ cat ~/.my.cnf

You can also store user and host there. These options will be used by all mysql clients unless you override them. If you often connect to the same server with the same credentials, setting these can save you a lot of typing.

You need to make sure that your my.cnf is only readable by your user. For example, chmod 600 ~/.my.cnf.

share|improve this answer
Perfect, thanks! – Will Martin Sep 21 '11 at 15:44

Create a ~/.my.cnf file in your $HOME with below content:

user     = root
password = pa$$w0rd
host     = mysql.server.ip.address

and make it can be readable by only you:

chmod 600 ~/.my.cnf
share|improve this answer
Thanks! Upvoted, but unfortunately I can't accept both answers. – Will Martin Sep 21 '11 at 15:45

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.