Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have to log into multiple MYSQL DB's on different hosts via mysql cli. is it possible to save these logins so I don't have to trackdown/remember the credentials?

share|improve this question
1  
do you connect to the mysql network port or ssh in and connect to the db locally? – Call me V Jan 15 '11 at 17:07

1 Answer

up vote 1 down vote accepted

Based on a discussion at http://bugs.mysql.com/bug.php?id=17627 I use the following method to automatically log into different mysql servers:

File /path/to/my-host1-cnf.txt

[client]
host="hostname1"
user="username1"
password="password1"
database="database1"

File /path/to/my-host2-cnf.txt

[client]
host="hostname2"
user="username2"
password="password2"
database="database2"

Connect to host1, database1 with saved credentials above:

mysql --defaults-file="/path/to/my-host1-cnf.txt"

Connect to host2, database2 with saved credentials above:

mysql --defaults-file="/path/to/my-host2-cnf.txt"

Hope this helps :-)

share|improve this answer
This looks like it might be what I need. Thanks! – veilig Apr 27 '11 at 6:10

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.