patternsqlCritical
Is it possible to have passwords configured per database or per host in .my.cnf
Viewed 0 times
perpasswordscnfdatabasepossiblehostconfiguredhave
Problem
I have the following in my
but this is not the password I use for every user@host/database I connect to. Is there some way to specify in the config different passwords for different things so I don't have to type them in?
~/.my.cnf[client]
password="somepass"but this is not the password I use for every user@host/database I connect to. Is there some way to specify in the config different passwords for different things so I don't have to type them in?
Solution
As I answered here, you can add a section for each user/host/db you connect to using the syntax in your
Once this is in your user's
~/.my.cnf:[clienthost1] # Note: client + host1
user=myuser
password=mypass
database=dbname
host=server.location.comOnce this is in your user's
.my.cnf, you can utilize it by doing this on a command line:$ mysql --defaults-group-suffix=host1Code Snippets
[clienthost1] # Note: client + host1
user=myuser
password=mypass
database=dbname
host=server.location.com$ mysql --defaults-group-suffix=host1Context
StackExchange Database Administrators Q#3889, answer score: 83
Revisions (0)
No revisions yet.