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?

link|improve this question

feedback

2 Answers

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
[client]
password="password"

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.

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

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

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

and make it can be readable by only you:

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

Your Answer

 
or
required, but never shown

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