Communication protocols in MySQL

Generally, MySQL supports connections between clients and the server using several networking protocols. Below are the main protocols which are used by client to connect with MySQL server.

  • TCP/IP
  • Unix socket file
  • Named pipe
  • Shared memory

TCP/IP connections are supported by any MySQL server unless the server is started with the –skip-networking option. These connections are supported by all type of Operating Systems and also connect from locally or remotely.

Unix socket file connections are supported by all Unix servers and this can be connect from local only.

Named-pipe connections are supported only by Windows servers and are disabled by default. To enable named-pipe connections, you have to start the mysql-nt server with the –enable-named-pipe option.

Shared-memory connections are supported by all Windows servers and are disabled by default. To enable shared-memory connections, you have to 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 but If the client will run on a different host,connections always use TCP/IP. MySQL communication protocols are implemented by various libraries and program drivers. Client programs included with MySQL distributions like mysql, mysqladmin etc establish connections to the server using the native C client library.

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 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.

Ref: MySQL Manual

One thought on “Communication protocols in MySQL”

  1. How do you start the server with the “-shared-memory” option? I have not been able to find this information anywhere. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *