2009-08-20

MySQL - Passwordless login within bash script

As like the previous post about passwordless login within Bash script, this post is about how to connect to MySQL database server using Bash script without MySQL client prompting for login.

Here it is :

  1. Create a hidden file (in home directory where the user would run the script) named ~/.my.cnf with the below sample contents :
  2. [mysql]
    user=bob
    password=secret
  3. In Bash script, specified the user name "bob" to query the database and it will not prompt for password.
  4. That's all.

Hasta la vista !!!

No comments: