The preferred method to pass authentication parameters to the
server (e.g., user, password, host) is through the MySQL personal
configuration file $HOME/.my.cnf (or c:/my.cnf under Windows).
Since specifying passwords on calls to
dbConnect
is a very bad idea (and so is specifying passwords through
shell variables),
the client code parses the configuration file $HOME/.my.cnf;
this file consists of zero or more sections, each starting with a
line of the form [section-name]
, for instance$ cat $HOME/.my.cnf
# this is a comment
[client]
user = dj
host = localhost
[rs-dbi]
database = s-data
[lasers]
user = opto
database = opto
password = pure-light
host = merced
...
[iptraffic]
host = data
database = iptraffic
This file should be readeable only by you.
Inside each section, MySQL parameters may be specified one per line
(e.g., user = opto
).
MySQL always considers default options from the [client]
group
for connecting to a server. To override or add additional options, R MySQL
combines default options from the [rs-dbi]
group, but you may specifiy you own
group in the dbConnect
call to tailor your environment. Note that
to override options, you must place your group after the [client]
group
in configuration file.
For instance, if you define a group, say, [iptraffic]
,
then instead of including all these parameters in the
call to dbConnect
, you simply supply the
name of the group
,
e.g., dbConnect(mgr, group = "iptraffic")
.
The most important parameters are user
,
password
, host
,
and dbname
.