Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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.

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:

[mysql]
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

 
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.