23.2. Communication Protocols


A MySQL client program can connect to a server running on the same machine. This is a local connection. A client can also connect to a server running on another machine, which is a remote connection.

MySQL supports connections between clients and the server using several networking protocols, as shown in the following table.

Protocol

Types of Connections

Supported Operating Systems

TCP/IP

Local, remote

All

Unix socket file

Local only

Unix only

Named pipe

Local only

Windows only

Shared memory

Local only

Windows only


Some protocols are applicable for connecting to either local or remote servers. Others can be used only for local servers. Some protocols are specific to a given operating system.

  • TCP/IP connections are supported by any MySQL server unless the server is started with the --skip-networking option.

  • Unix socket file connections are supported by all Unix servers.

  • Named-pipe connections are supported only on Windows and only if you use one of the servers that has -nt in its name (mysql-nt, mysql-max-nt). However, named pipes are disabled by default. To enable named-pipe connections, you must start the -nt server with the --enable-named-pipe option.

  • Shared-memory connections are supported by all Windows servers, but are disabled by default. To enable shared-memory connections, you must start the server with the --shared-memory option.

From the client perspective, a client run on the same host as the server can use any of the connection protocols that the server supports. If the client is run on a different host, connections always use TCP/IP.

To enable you to indicate which kind of connection to use and which server to connect to, MySQL client programs understand a standard set of command-line options. Section 1.2, "Invoking Client Programs," discusses the syntax for these options and how to use them when invoking client programs.

MySQL communication protocols are implemented by various libraries and program drivers. Client programs included with MySQL distributions (mysql, mysqladmin, and so forth) establish connections to the server using the native C client library. However, other interfaces are available, such as the MySQL Connectors mentioned in Section 23.1, "Client/Server Overview."

The different connection methods are not all equally efficient:

  • In many Windows configurations, communication via named pipes is much slower than using TCP/IP. You should use named pipes only when you choose to disable TCP/IP (using the --skip-networking startup parameter) or when you can confirm that named pipes actually are faster for your particular setup.

  • On Unix, a Unix socket file connection provides better performance than a TCP/IP connection.

  • On any platform, an ODBC connection made via MySQL Connector/ODBC is slower than a connection established directly using the native C client library. This is because ODBC is layered on top of the C library, which adds overhead.

  • On any platform, a JDBC connection made via MySQL Connector/J is likely to be roughly about the same speed as a connection established using the native C client library.



MySQL 5 Certification Study Guide
MySQL 5.0 Certification Study Guide
ISBN: 0672328127
EAN: 2147483647
Year: 2006
Pages: 312

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net