Rechercher dans le manuel MySQL
5.8.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
--port=
to connect using TCP/IP to a remote server, withport_number
--host=127.0.0.1
--port=
to connect using TCP/IP to a local server, or withport_number
--host=localhost
--socket=
to connect to a local server using a Unix socket file or a Windows named pipe.file_name
Start the client with
--protocol=TCP
to connect using TCP/IP,--protocol=SOCKET
to connect using a Unix socket file,--protocol=PIPE
to connect using a named pipe, or--protocol=MEMORY
to connect using shared memory. For TCP/IP connections, you may also need to specify--host
and--port
options. For the other types of connections, you may need to specify a--socket
option to specify a Unix socket file or Windows named-pipe name, or a--shared-memory-base-name
option to specify the shared-memory name. Shared-memory connections are supported only on Windows.On Unix, set the
MYSQL_UNIX_PORT
andMYSQL_TCP_PORT
environment variables to point to the Unix socket file and TCP/IP port number before you start your clients. If you normally use a specific socket file or port number, you can place commands to set these environment variables in your.login
file so that they apply each time you log in. See Section 4.9, “MySQL Environment Variables”.Specify the default Unix socket file and TCP/IP port number in the
[client]
group of an option file. For example, you can useC:\my.cnf
on Windows, or the.my.cnf
file in your home directory on Unix. See Section 4.2.2.2, “Using Option Files”.In a C program, you can specify the socket file or port number arguments in the
mysql_real_connect()
call. You can also have the program read option files by callingmysql_options()
. See Section 28.7.7, “C API Function Descriptions”.If you are using the Perl
DBD::mysql
module, you can read options from MySQL option files. For example:$dsn = "DBI:mysql:test;mysql_read_default_group=client;" . "mysql_read_default_file=/usr/local/mysql/data/my.cnf"; $dbh = DBI->connect($dsn, $user, $password);
See Section 28.9, “MySQL Perl API”.
Other programming interfaces may provide similar capabilities for reading option files.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-multiple-server-clients.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.