Using Client Programs in a Multiple-Server Environment
556
shell>
mysqladmin --host=host_name --port=port_number variables
With the information displayed by that command, you can tell what option values not to use when
configuring an additional server.
If you specify
localhost
as the host name,
mysqladmin
defaults to using a Unix socket
file connection rather than TCP/IP. To explicitly specify the connection protocol, use the
--
protocol={TCP|SOCKET|PIPE|MEMORY}
[231]
option.
You need not compile a new MySQL server just to start with a different Unix socket file and TCP/IP port
number. It is also possible to use the same server binary and start each invocation of it with different
parameter values at runtime. One way to do so is by using command-line options:
shell>
mysqld_safe --socket=file_name --port=port_number
To start a second server, provide different
--socket
[422]
and
--port
[417]
option values, and
pass a
--datadir=path
[404]
option to
mysqld_safe
so that the server uses a different data
directory.
Alternatively, put the options for each server in a different option file, then start each server using a
--
defaults-file
[240]
option that specifies the path to the appropriate option file. For example, if the
option files for two server instances are named
/usr/local/mysql/my.cnf
and
/usr/local/
mysql/my.cnf2
, start the servers like this: command:
shell>
mysqld_safe --defaults-file=/usr/local/mysql/my.cnf
shell>
mysqld_safe --defaults-file=/usr/local/mysql/my.cnf2
Another way to achieve a similar effect is to use environment variables to set the Unix socket file name
and TCP/IP port number:
shell>
MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
shell>
MYSQL_TCP_PORT=3307
shell>
export MYSQL_UNIX_PORT MYSQL_TCP_PORT
shell>
mysql_install_db --user=mysql
shell>
mysqld_safe --datadir=/path/to/datadir &
This is a quick way of starting a second server to use for testing. The nice thing about this method is
that the environment variable settings apply to any client programs that you invoke from the same shell.
Thus, connections for those clients are automatically directed to the second server.
Section 2.21, “Environment Variables”
, includes a list of other environment variables you can use to
affect MySQL programs.
On Unix, the
mysqld_multi
script provides another way to start multiple servers. See
Section 4.3.4,
“
mysqld_multi
— Manage Multiple MySQL Servers”
.
5.3.4. Using Client Programs in a Multiple-Server Environment
To connect with a client program to a MySQL server that is listening to different network interfaces from
those compiled into your client, you can use one of the following methods:
• Start the client with
--host=host_name
[231]
--port=port_number
[231]
to connect using TCP/
IP to a remote server, with
--host=127.0.0.1
[231]
--port=port_number
[231]
to connect
using TCP/IP to a local server, or with
--host=localhost
[231]
--socket=file_name
[232]
to
connect to a local server using a Unix socket file or a Windows named pipe.
• Start the client with
--protocol=TCP
[231]
to connect using TCP/IP,
--protocol=SOCKET
[231]
to connect using a Unix socket file,
--protocol=PIPE
[231]
to connect using a named pipe, or
--protocol=MEMORY
[231]
to connect using shared memory. For TCP/IP connections, you may
also need to specify
--host
[231]
and
--port
[231]
options. For the other types of connections,
you may need to specify a
--socket
[232]
option to specify a Unix socket file or Windows named-
pipe name, or a
--shared-memory-base-name
[232]
option to specify the shared-memory name.
Shared-memory connections are supported only on Windows.
Содержание 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 ...