[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
MySQL client programs generally require that you specify connection
parameters when you want to access a MySQL server: the host you want
to connect to, your username, and your password. For example, the
mysql
client can be started like this, where optional arguments are
indicated by `[' and `]':
shell> mysql [-h host_name] [-u user_name] [-pyour_pass] |
Alternate forms of the -h
, -u
, and -p
options are
--host=host_name
, --user=user_name
, and
--password=your_pass
. Note that there is no space between
-p
or --password=
and the password following it.
Note: Specifying a password on the command line is not secure!
Any user on your system may then find out your password by typing a command
like: ps auxww
. See section 4.3.2 Using Option Files.
mysql
uses default values for connection parameters that are not given
on the command line:
localhost
.
-p
is missing.
Thus, for a Unix user joe
, the following commands are equivalent:
shell> mysql -h localhost -u joe shell> mysql -h localhost shell> mysql -u joe shell> mysql |
Other MySQL clients behave similarly.
On Unix systems, you can specify different default values to be used when you make a connection, so that you need not enter them on the command-line each time you invoke a client program. This can be done in a couple of ways:
[client]
section of the
`.my.cnf' option file in your home directory. The relevant
section of the file might look like this:
[client] host=host_name user=user_name password=your_pass |
See section 4.3.2 Using Option Files.
mysql
using MYSQL_HOST
. The
MySQL username can be specified using USER
(this is for
Windows and NetWare only). The password can be specified using MYSQL_PWD
(but this is insecure; see the next section). See section E. Environment Variables.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |