Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access mysql via shell 1

Status
Not open for further replies.

max1x

Programmer
Jan 12, 2005
366
US
I am trying to run queries against a mysql DB, for which I've been provided a uid & pwd, but for this I first have to login as:

Code:
mysql -u xx -p
password: xxxx
use dbName;
query

Is there a way to access the DB directly from a *nix shell and automate the login/query execution process.
 
I think I've found a way to access the DB directly using:
Code:
mysql -D -u xx
but I'm not sure how to grant the proper pivs to not be prompted for a password.

 
You can put the username and password into the user's ~/.my.cnf, like so:

[mysql]
password=password

Set the permissions on the file to 600.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top