Server Fault is a question and answer site for system and network administrators. 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 am using the mysql command line client and I do not want to need to provide the password every time I start the client. What are my options?

share|improve this question
Please accept answers on some of your previous questions, as it appears that several of those answers have been correct solutions - click the outlined checkmark to the left of the answer. – Shane Madden Feb 10 '12 at 20:02
up vote 5 down vote accepted

Create a file named .my.cnf in your home directory that looks like this. Make sure the filesystem permissions are set such that only the owning user can read it (0600).

host     = localhost
user     = username.
password = thepassword
socket   = /var/run/mysqld/mysqld.sock
#database = mysql

Since you also tagged your question mysqldump you should look at this question.

Using mysqldump in cron job without root password

share|improve this answer
This is great it worked .. Thanku – Trip Feb 14 '12 at 16:36
If the answer solved your problem then you should click the check mark to accept it. – Zoredache Feb 14 '12 at 16:41

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.