Connecting to the MySQL Server
230
shell>
mysql
Because there are no parameter options, the default values apply:
• The default host name is
localhost
. On Unix, this has a special meaning, as described later.
• The default user name is
ODBC
on Windows or your Unix login name on Unix.
• No password is sent if neither
-p
nor
--password
[231]
is given.
• For
mysql
, the first nonoption argument is taken as the name of the default database. If there is no
such option,
mysql
does not select a default database.
To specify the host name and user name explicitly, as well as a password, supply appropriate options
on the command line:
shell>
mysql --host=localhost --user=myname --password=mypass mydb
shell>
mysql -h localhost -u myname -pmypass mydb
For password options, the password value is optional:
• If you use a
-p
or
--password
[231]
option and specify the password value, there must be no
space between
-p
or
--password=
[231]
and the password following it.
• If you use a
-p
or
--password
[231]
option but do not specify the password value, the client
program prompts you to enter the password. The password is not displayed as you enter it. This is
more secure than giving the password on the command line. Other users on your system may be
able to see a password specified on the command line by executing a command such as
ps auxw
.
See
Section 6.1.2.1, “End-User Guidelines for Password Security”
.
As just mentioned, including the password value on the command line can be a security risk. To avoid
this problem, specify the
--password
or
-p
option without any following password value:
shell>
mysql --host=localhost --user=myname --password mydb
shell>
mysql -h localhost -u myname -p mydb
When the password option has no password value, the client program prints a prompt and waits for
you to enter the password. (In these examples,
mydb
is not interpreted as a password because it is
separated from the preceding password option by a space.)
On some systems, the library routine that MySQL uses to prompt for a password automatically limits
the password to eight characters. That is a problem with the system library, not with MySQL. Internally,
MySQL does not have any limit for the length of the password. To work around the problem, change
your MySQL password to a value that is eight or fewer characters long, or put your password in an
option file.
On Unix, MySQL programs treat the host name
localhost
specially, in a way that is likely different
from what you expect compared to other network-based programs. For connections to
localhost
,
MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even
if a
--port
[231]
or
-P
option is given to specify a port number. To ensure that the client makes
a TCP/IP connection to the local server, use
--host
[231]
or
-h
to specify a host name value
of
127.0.0.1
, or the IP address or name of the local server. You can also specify the connection
protocol explicitly, even for
localhost
, by using the
--protocol=TCP
[231]
option. For example:
shell>
mysql --host=127.0.0.1
shell>
mysql --protocol=TCP
The
--protocol
[231]
option enables you to establish a particular type of connection even when
the other options would normally default to some other protocol.
On Windows, you can force a MySQL client to use a named-pipe connection by specifying the
--
pipe
[231]
or
--protocol=PIPE
[231]
option, or by specifying
.
(period) as the host name. If
named-pipe connections are not enabled, an error occurs. Use the
--socket
[232]
option to specify
the name of the pipe if you do not want to use the default pipe name.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...